Let's distinguish between cross-domain and subdomain tracking.
- Cross Domain Tracking - This deals with measurement between different domains. E.g. You have a store on mystore.com or a blog on myblog.com and you want to view them as if they are one property in Google Analytics. In this scenario, you need cross-domaincross-domain tracking.
- Subdomain Tracking - This is needed if you have a website with pages on a subdomain (e.g. mystore.com and landingpage.mystore.com).
This article will walk through subdomain tracking, not cross domain tracking.
There are two primary concerns when tracking on a subdomain
- Keeping the Session Intact - What we don't want to happen is for a session to get fractured when the shopper moves from the subdomain to the main domain. A fractured session means you'll get multiple sessions in Google Analytics when you should only have one.
- Keeping the Attribution Intact - Additionally, we'll want to make sure that the associated marketing channel or website that drove your shopper to your website is given recognition for the actions the shopper then takes on your website (e.g. a purchase). We don't want the attribution details to be lost when the shopper moves from the subdomain to the main domain.
The good news is: you can solve both these challenges by walking through the below steps.
The good news is: you can solve both the above challenges by walking through the below steps.
In your Google Tag Manager Account, find your Google Analytics Setting Variable.
In this variable, make sure that the Cookie Domain is set to auto.
What does this do? By doing this we set the ga cookie at the highest level available on the domain (making it available to both the subdomain and the main domain). This helps GA to understand the events as a single session.
In Google Analytics, navigate to your Referral Exclusion List Settings.
Add your subdomain as a referral exclusion.
What does this do? This prevents your subdomain showing up as a referral source in your GA reports.
Navigate to the Subdomain Link Decorator Pre-Built Tag in your Elevar App.
Download the Pre-Built Tags.
Import the Pre-Built Tags into Google Tag Manager
In the tag titled Update After Import Subdomain Link Decorator, update line 4 with your main domain URL
Warning: Please include the ending ".com", ".ca", etc. Please do not include the beginning https/http or a trailing slash.
In the trigger titled Update After Import All Subdomain Pages, update the first Page URL rule with your own subdomain & main domain.
What if I have multiple subdomains?
If this is the case, use the following format: SUBDOMAIN.DOMAIN|SUBDOMAIN.DOMAIN
Correctly Formatted Examples:
When ready, press Submit > Publish in Google Tag Manager to make these changes go live.
There's two items you'll want to QA to know if your subdomain tracking is working:
Use Chrome's Developer Network Tab to see if the CID property in your Google Analytics hits remains consistent as you navigate from your subdomain to your main domain.
- On your Subdomain, look at the Google Analytics hit in your Chrome Developer Network Tab for the CID property. Note the value.
- Click a link that leads to your main domain.
- On your main domain, look at the Google Analytics hit in your Chrome Developer Network Tab for the CID property. Note the value.
- If the value is the same on your subdomain & main domain, then your session stayed intact!
- Add test URL parameters to your subdomain URL
- Example: try.getelevar.com/?utm_source=testsource&utm_medium=testmedium
- Click a link that leads to your main domain
- Check to see if the URL parameters are now present in the URL of your main domain
- It should look similar to: getelevar.com/collections/products?utm_medium=testmedium&utm_source=testsource
- If you are seeing the parameters appearing in your main domain URLs, it's working!
Updated about 1 month ago