Have you been researching how best to set up Google Analytics for your SaaS or Ecommerce site where you are using subdomains?
Well, this post is simple. We will address these two very specific use cases.
Google Analytics Setup for SaaS and basic E-com sites with sub-domains!
In most cases a business is using sub domains and not actually two separate domains. Hence, the goal is to make sure that users from sub domain are not counted twice. That is the main challange we want to solve in this post.
If a user starts a session on offer.ecomsite.com and then lands on ecomsite.com to complete the purchase we want to make sure that user is only counted once not twice by Google Analytics.
Similarly, most SaaS have a setup where app.saas.com is where the users login and saas.com would be their marketing site.
In all the above use cases, we are using a sub domains, and not a new separate domain.
Now, after much research here is what I found regarding sub domain tracking.
Yep, per Julian from Measure School,
"Technically you don't need cross-domain tracking (for sub-domains), just make sure your auto cookie setting is true"
You need not do much of anything if you are using Google Tag Manger to fire off your Google Analytics.
Using GTM, for sub-domain tracking you just need to make sure you have these things in order.
Inside GTM - Create a Google Analytics Variable
Inside GTM - Make sure the Google Analytics Variable has Cookie Domain setting of 'auto’ which is default.
Inside GTM - Configure Tag to fire on all pages.
In Google Analytics - add main domain to Referral Exclusion List (no sub-domains)
Test - Use Chrome Tag Assistant to check the GTM and Google Analytics codes are firing and use GA Debugger to see session is maintained across sub-domains.
If you have implemented the above steps in your Tag Manager and are firing off the GTM code on your main and all sub-domains, the Chrome Tag Assistant will look something like this.
Here is how to test if the userid stays the same across all your sub-domains and the main domain.
a) GA Debugger extension to turn it on
b) right click on page and click on 'inspect'
c) Click on 'console' tab and sarch for 'cid'
d) Click on a link within your page that will take user to the 'sub domain' or main domain
e) Clikc on 'inspect' on this page and search for 'cid'
The 'cid' should be the same on both your main domain and the subdomain
Basically, we want to check if the user session is tracked as one user and not two if you hop from one sub-domain to another.
Yep. that is all you need to start gathering accurate data if your use case involves sub-domains!
Now, if the sub-domain use case does not apply to you and you have two unique domains and need to combine your Google Analytics into one account, here is the best video I found on Cross-domain Tracking with GTM by Julian from Measure School that will walk you through the setup.