What is cross domain tracking?
Quite often there is a lot of confusion when it comes to cross domain tracking. In this blogpost I will talk through the following:
- What is cross domain tracking?
- How does it work & what does it do?
- What are subdomains?
- What happens if we don’t do this?
What is cross domain tracking?
Cross domain tracking is a way of allowing Google Analytics to track a visitor as a continuous session on two or more related sites. For example when tracking www.sitea.com and www.siteb.com in the same GA Web Property.
How does it work & what does it do?
Google Analytics (Universal Analytics) uses a First Party cookie called _ga. For our example, this means it uses 1 cookie for www.sitea.com, apps.sitea.com, blog.sitea.com and other sub domains. This is easily done by setting the cookie domain setting in GTM to auto.
This _ga cookie stores information about the visitor and their session and has the following attributes:
- Cookie name – ‘_ga’ by default.
- Cookie domain – it is the domain at which the cookie is set up. For www.sitea.com this means that the cookie domain is ‘.sitea.com’. (without the ‘www’ prefix)
- Cookie Path – this is the path at which the cookie is set up. This is set as the root directory of the domain ‘/’.
- Cookie Expires – It is the time in seconds after which the _ga cookie will expire. By default the _ga cookie expires after 2 years from the time it was last refreshed.
Now, as this is a first party cookie, it cannot share this information with other domains. This is where Cross Domain Tracking comes into play. In this case we need to instruct it to share the values of the sitea.com cookie with the cookie of siteb.com.
What this will do is append the _ga cookie values to the urls where the domain changes using a query string by default. This can also be changed to a url fragment if you are not a fan of query strings. GA will recognize these added parameters in these urls ensure that the GA cookie adopts these values.
This looks something like this: http://www.siteb.com/?_ga=1.123456789.9876543210.123456789
What are subdomains?
Fairly often, cross domain tracking gets confused with subdomain tracking. A subdomain is essentially a subdivision of a domain that, if used correctly, helps splitting up different areas of the website. In a nutshell we can explain it using this structure: https://subdomain.domain.co.uk.
What happens if we don’t do this?
Measuring what users do on your websites will be severely impacted. Traffic sources won’t be attributed correctly and the number of sessions will be inflated. It will be impossible to see which marketing channels are more successful at driving valuable traffic than others. The list goes on. In a nutshell, it will be impossible to make any decisions based on the data collected in Google Analytics.
Of course there are some scenarios where cross domain tracking is not possible, mainly due to not being able to get GA implemented onto those domains. One such scenario is applicable to payment gateways (for those of you who have a transactional website). For these you will need to make use of GA’s referral exclusion list which can be accessed via the GA Admin panel.
Next week, I will follow this up with a simple example and some screenshots.
Part 2 is now live and can be viewed here.