Are you seeing a ton of traffic to pages on your website that contain:


If so, you have been hit by a bot attack. This bot uses the App Measurement Protocol to send fake GA hits to your account. If you are using Google Tag Manager (GTM), read on to learn how you can prevent these bot attacks in the future.

If you are simply looking to clean up your existing reports, apply the following advanced segment to your reports:

Note that you may need to edit the segment to include all of the SPAM and BOT hits to your site.

Step 1: Create a Constant Variable with a random string

Create a new variable constant. I named mine “SPAM Filter Variable.”

Generate a random string and place it in the variable. I used a 20-character string generated from a password tool.

Step 2: Update your GA Settings Variable to pass the new variable into a custom dimension

The next step is to update your GA Settings variable (or in every pageview and event tag if you are not using a settings variable). Find a custom dimension you are not using and set it to the SPAM Filter Variable, as shown below.

Don’t publish these updates until Step 4.

Step 3: Set up a new custom dimension in GA

Now open your GA property. Go to Admin > Property > Custom Definitions > Custom Dimensions.

Add a Hit scoped custom dimension for the same index you set up in GTM. I named mine “Hit from GTM,” as shown below.

Step 4: Publish your GTM updates

Now publish your GTM workspace.

Step 5: Create a filter to only include hits with your new variable

Now go back to GA. Create a filter to only include traffic that comes with your custom string in the custom dimension.

Note: your Filter Field is the name of the custom dimension you used. It can take a few minutes for the custom dimension’s name to appear in your filter options.

Use the following settings:

Step 6: QA that everything is working

Finally, go to the real-time report and confirm your site is still seeing traffic. We also recommend keeping an eye on your traffic for the next day or two.