Use Google Tag manager to filter ghost traffic from Google Analytics
If you're reading this post you're probably trying to remove ghost referral traffic from your Google Analytics. This is traffic that doesn't actually hit your site, but leaves a trail in your analytics referrals of a spike in traffic alongside zero time on site which can disrupt your metrics.
If you're seeing referral spikes in your Google Analytics it might be suffocating the remaining legitimate traffic and making marketing analysis a frustrating task. Here's the measure we're experimenting with to remove this traffic from our Analytics data. We only did this this 2 days ago and since then it's filtered out all of this traffic successfully from our data. We're monitoring this and will amend this post if this changes.
TL;DR METHOD: In Tag Manager we added a Dimension Value to the Page View tag which fires on every time a user hits a site page. As the bot traffic is ghost traffic that never actually visits your site it doesn't fire this tag. You can then set up a filter in Analytics with a custom dimension that references this tag, hence filtering out the ghost traffic.
To carry out this method you'll need to be using Google Tag Manager, find out how to implement this on your site using this training material from Analytics Academy. If you're new to Tag Manager you're going to need to set aside a few hours of your life to get your head around Tag Manager implementation. We still have plenty to do with our Tag Manager implementation but we thought we'd share this early in case we can save someone a few hours.
If you're on Squarespace, we followed this post from Yo! Web to get Tag Manager to play nicely with Squarespace.
Step 1: If you're new to Tag Manager you'll need to set up a Tag to fire on all page views. Detailed steps to do this are explained in the Analytics Academy training material. If you're using Squarespace remember to remove your tracking code from Settings>Advanced>External Services>Google Analytics Account Manager field as well.
Step 2a: Within the Tag settings click edit on configure tag and add a custom dimension. This needs to have the same index number as you will set up in Analytics, in our case this is 1 and we used a dimension value of not-a-bot.
Step 2b: Remember to test this in your website preview.
Hit 'preview and debug' navigate to your website in a new window and check the tag fires. If you drill into the tag you need to confirm the tag contains the dimension as below. Remember to go back to Tag Manager and publish the changes to your tag.
Step 3a: Set up a custom dimension in your Property in Analytics.
Step 3b: We used a custom dimension called gaSpamFilter with an index of 1. Note if your index number is different you'll need to change this number in Tag Manager to the same number.
Step 4a: Set up a your bot filter. Note we're trying this in our test view. Once we've tried this for a couple of weeks to check it's successful we'll roll this out to our master view.
Step 4b: Bot filter detailed settings. Set the filter to 'include' the custom dimension.
Hope this helps and saves you a couple of hours! Please let us know how you got on if you found this helpful!