I created a new Chrome Extension: Internalize for Google Analytics. This is its very first version. It only works on websites with Universal Analytics.
The idea is that with the extension you can push a custom dimension value to your currently active session. You can then use a profile filter in GA to block traffic with this custom dimension value. It’s useful when blocking internal traffic with more traditional means (IP address or various GTM workarounds) won’t work.
How to use it
- Create new session-scoped custom dimension in GA property settings
- Make note of the index number of this new dimension
- Go to the website whose traffic is being tracked to the property
- Click the extension to open a pop-up
- Add the index number to its designated place in the pop-up
- Click the button “Enable Internalize”
This sends a non-interaction event to the active session. The Event Category is “Internalize” and the Event Action is “Enable”.
A custom dimension value “true” is sent with this event, and it is this value that you should filter in your profile settings.
The screenshot above assumes that the name of the new custom dimension is “Internal”.
How it works
The extension first checks if Universal Analytics is implemented on the page. If it is, the extension icon turns blue to indicate that it’s ready to operate.
Once you add the index number and click “Enable Internalize”, the XMLHttpRequest() object is used to send a data package to Google Analytics servers. This payload contains the following:
- The tracker ID of the first ‘ga’ object found on page
- The client ID of the first ‘ga’ object found on page
- The event data with the custom dimension
A cookie with a 30 minute expiration is written as well to prevent multiple pushes in a short period of time.
There are some caveats right now. First of all, you can send the event to ANY Universal Analytics website, because it accesses the ‘ga’ object found on the page. This is obviously a problem, and even though there’s not too much damage you can cause with a clickable browser extension (which sends non-interaction data), it’s still annoying to see extra hits on your site.
Also, it only works with the first ‘ga’ object found on the page, so if you have multiple Universal Analytics properties tracked on a single page, this will only work on one of them.
So here’s a feature list I’ve drawn up for the near future:
- Add an Options panel
- Choose domains for which the extension will only work (now it works for all)
- Choose a tracker ID for which the extension will only work (it will look for this tracker ID from the ‘ga’ object)
- Choose whether just a cookie is set or whether the Measurement Protocol is used as well
- Add support for multiple tracker IDs
Working with internal traffic is a pain, and I hope this extension helps some of you with unwanted hits.