Prevent Employees from Appearing in Analytics (update for Universal Analytics)
As promised, here's the article with a walkthrough of how to exclude employee visits, such as content authors and business users, from your Google Analytics Universal Analytics profile. This article is a follow up to an earlier one written on excluding employee visits for the classic (async) version of Google Analytics. Both articles address the need through a persistent Web browser cookie and a GA filtering rule.
Note: This article is written for Google Analytics Universal Analytics. The code and configurations will not work with async. See the earlier article on excluding employee visits from Google Analytics async.
Google frequently changes the interfaces for both administration and reporting. This walkthrough is accurate as of the writing of this article. Regardless of where something is found in the interface, the terms and process mentioned here should remain the same.
We'll follow the same three step structure from the async article. I'll glaze over any elements covered in the previous article so we can move directly to the implementation. That information is available in the async article.
Step 1: Assign and Set Custom Dimension on your site’s domain
Step 2: Test before implementing in production profile
Step 3: Configure filter within production Google Analytics profile(s)
Step 1: Assign and Set Custom Dimension on your site’s domain
Assign Custom Dimension (Server Side)
Before we set the variable value, we need to set the variable name. GA's async custom variables names are set client side (the variable we set in the previous post is actually an even older variable from what I'd now call GA antique synchronous tracking, and doesn't even offer a variable name). In GA's Universal Analytics, custom dimension names are now set server side. This makes management of these names much more streamlined since variable names are stored in one central place and you can avoid digging into the code to change them. Aside from this difference, GA Universal Analytics offers 20 custom dimensions, up from 5 in async (and one in antique sync). The rest is pretty similar, with hit level, session level and user level variables.
click on "Admin" in the top right.
under the "Property" column, expand "Custom Definitions"
click on Custom Dimensions
click on New Custom Dimension
For Name, enter "User Type",
For Scope, select "User"
Check Active
Save
Google Analytics Custom Dimension: in the Web Property that all the Profiles belong to, set a new Custom Dimension for User Type.
After you've saved the new Custom Dimension, note the index number assigned to this custom dimension. If you haven't set one before, this should be 1.
Google Analytics Custom Dimensions Table: after saving the new Custom Dimension, you will see it appear in a table with the Custom Dimension Name you assigned and the dimension's Index. The Index number is the slot you'll use in when setting the Custom Dimension Value on the client side.
Set Custom Dimension Value (Client Side)
GA's async custom variables values are set client side. This is no different in GA's Universal Analytics, with custom dimension values set client side on the page.
Create an orphan Web page hosted on your site's domain with your site's standard analytics code. For instance, http://foo.example.com/exclude-visitor-analytics.html. If you'd like, add a meta robots noindex tag to the page's head so it doesn't accidentally get crawled.
Ideally the dimension is set before ga('send', 'pageview'); rather than after it. If it's sent afterwards, the dimension is submitted with the next pageview rather than this current pageview.
ga('create', 'UA-XXXXXXX-X'); //set dimension prior to sending the pageview like so ga('set', 'dimension1', 'employee'); ga('send', 'pageview');
For simplicity, you can choose to add the code after sending the pageview by adding this to the HTML code of the orphan page, where dimension1 is the custom dimension slot you'll be using:
<script type="text/javascript"> ga('set', 'dimension1', 'employee'); </script>
If you already have custom dimensions, set an empty slot and document it where appropriate. Keep this slot exclusive for employee tracking.
Step 2: Test before implementing in production profile
Test with a separate profile to track only those pageviews containing the new custom dimension.
In your Google Analytics administrative interface, access your profile:
click on "Admin" in the top right
under "View (Profile)", expand "Filters"
click on New Filter
for Filter Name, enter "Exclude Employees"
select Custom filter
for Filter Type, select "Exclude"
For Filter Field, find "User Type" under Custom Dimensions
For Filter Pattern, type in employee
Set Case Sensitive to "No"
Save
Google Analytics Profile Filter: configure the production profile to exclude pageviews from any visitor that has the User Type custom dimension (from Step 1) set to "employee".
Step 3: Configure filter within production Google Analytics profile(s)
Now that you’ve tested the custom variable, you’re ready to move it to production. In your production Google Analytics profile(s), add a new filter to remove visitors that carry this custom variable. Follow the screenshot in Step 2, but select “Exclude” instead of “Include”.
Google Analytics Profile Filter: configure the production profile to exclude pageviews from any visitor that has custom variable set to “analytics-exclude”.











