Tracking Internal Traffic

Full text

(1)

Internal Traffic

with

Google Tag Manager

(2)

Track Internal Traffic with Google Tag Manager

Do you know GTM yet? Google Tag Manager is a powerful management tool to upgrade Google Analytics. Honestly, not many people care about it at all, judging from Google search volumes. The reason might be it seems superfluous to get into GTM when GA works just fine, and the learning curve...Well, it can feel quite massive. For people in eCommerce though, or for anyone who derives a KPI from traffic or clicks, the hassle of starting with GTM is absolutely worth it. You get clearer data, less noise, less BS and less false judgement. However there is something that GTM can and GA cannot, which is relevant to most brick-and-mortar, recently digitized or fully digital distributed businesses. It is tracking of internal traffic in such a case where the internal traffic comes from multiple locations.

Google Analytics Filters

Yep, the more or less infamous GA filters. A classic setup of "All website data", all traffic unmodified, and "External traffic", with internal hits filtered out. While it is fairly easy to separate internal traffic by excluding any number of IPs, the same way is not going to work if you intend to have someone to look your people over their shoulder. That is, setting up a view that would filter in the internal traffic only is possible only if you are tracking a single IP or IP range. It's the way the Google Analytics filters work: The exclude filter will gradually loop through all the statements and will only include the current visitor into the view if it doesn't fall under any of the exclusion filters. The include filter, on the other hand, will only track the visitor if all of the include conditions are matched. Therefore it's

(3)

Singapore - you've got to get a separate view for each IP range. It probably goes without saying that your Google Analytics will turn into mayhem for more than two IP addresses. Solution? With Google Tag Manager you can retrieve user's IP and lead it into an if - else loop to see if it matches any of the IP addresses defined by you. If so, label the hit as internal. If not, label it external. Then send the information to GA and create view based on the label: one view for all hits labeled internal, one view for all hits labeled external. Easy. Let's see how you go about it.

Tracking Internal Traffic with Tag Manager

We'll do this with Google Tag Manager v2. We've got Variables (static expressions), Triggers (conditions as to where to fire labeling) and Tags (this is where most of the work happens).

Variables

The only static variable you need to set is a data layer variable called getip. We'll use this variable to retrieve the visitors IP address. Set the variable name to ipaddress and choose some random default value like none.

(4)

Events

The only event you are setting up is gtm. Set it's name to gtm.js.

This will mark the moment when GTM loads its stuff and we can proceed to measuring the precious data.

(5)

Tags

First off, set up a basic all page view tracking tag. As the GTM snippet will replace the GA JavaScript used for all tracking, you need this general tag to measure the unfiltered traffic in "All website data". The type of tag is Universal Analytics, which is a new 2015 version of Google Analytics. Most definitely you'll have Universal Analytics by now - All GA accounts were auto-updated to the UA type this year. So, all you need is your tracking ID from Analytics. Set the tag to fire on all pages. Now for the tuff stuff. Create a Custom HTML tag with some cool name like IP Test. The custom HTML type comes with a big textarea into which copypaste the following code, exchanging the IP addresses for your internal IPs. Note that you need to have static IPs. There is a way to do that for IP ranges but as VPNs with a static address are widely used, I won't cover that here.

Indeed, feel free to add or leave out the or-statements || getip == "..." , depending on

how many IPs you need to check. I have tried it with some 14 IPs so you don't have to be shy.

(6)

The IP test should fire on GTM load. That means, set the trigger to gtm. <script> var getip = {{getip}}; // Retrieves the IP from the data layer if (getip == "11.222.333.444" || getip == "11.221.331.441" || getip == "11.220.330.440" ) { dataLayer.push({"event": "internal"}); } else { dataLayer.push({"event": "external"}); } </script> The task of that code snippet is to retrieve the IP address of your visitor and label it. For the labeling we use Events, already known from Google Analytics alone. Quite traditionally events are used to measure how many people clicked a link or displayed translated content. But thanks to GTM events can be used on load, too. What we need to do now is to have GA detect the occurrence of the event. For that you need to set up a Universal Analytics tag. Now, if you only want to track internal vs. all traffic, you only need one more tag. If you want a setup of All / Internal only / External only, you need two tags. The final analytics tag will link your GA account with the labeling on your website. Simply fill in your analytics ID, track the event categorized as internal or external, and let the tag fire on all pages.

(7)

The final step takes place in Google Analytics - setting up the views. Don't forget to keep one unmodified, unfiltered and completely natural view to have some baseline for comparison. For the rest of it, create a new view with a single custom filter. It should only include traffic with an event called internal (or external, whatever you are setting up). Written by J. for 88development / hq@88dvlp.com / Bitcoin is not evil.

Figure

Updating...

References

Updating...

Related subjects :