Tidy up your subdomain and multidomain web metrics with Google Tag Manager
SITUATION Let’s suppose that you have two sites to track, a main site and its subdomain
- www.mysite.xyz
- thirdlevel.mysite.xyz (for example it can be a specific product minisite or an ecommerce platform, a campaign landing page, etc.)
OBJECTIVE You want to monitor both all visits under one main Google Analytics profile (now called view) and also each single site separately. So you are planning to have at least three GA views.
PROCEDURE A standard way to distinguish pages after multidomain tracking can be made through a view where the hostname is added to the URI: this way pages will be distinguished by their hostname (normally absent on GA) as follows:
- www.mysite.xyz/index.php
- thirdlevel.mysite.xyz/index.php
- etc…
Here is an alternative approach through Google Tag Manager:
1. Create a GTM container for the whole web property
2. On the container create two different GATC tags, each bringing data to the same GA property ID (UA-xxxxxxxxx-x). You can call GATC-main and GATC-third-level (you can use spaces if you like)
3. Mind the Rules! Each GATC tag need to have a Rule that activate it only when the visitor is on the relative site. For example, GATC-third-level tag will have the following rule:
4. Now just one more step – the most important – add a virtual page to GATC-third-level:
4.1 Before doing that create a Macro called path (or any other name) to collect URL / Path
4.2 Then add it to the Virtual Page Path
PLEASE NOTE – If you don’t follow this step, your pageviews will merge together when having the same name (e.g. index.php pageviews from the main domain will be summed up to index.php pageviews from the subdomain). You can still create separate profiles (views) for each site using a filter that distinguish traffic to the hostname (e.g. mysite vs thirdlevel.mysite) but you will not be able to have the whole view under one profile (mysite + thirdlevel.mysite but differentiated with a virtual folder).
5. change the Rule TO GATC-main tag in order to activate it only when the visitor is on your main domain (not the third-level); no need to add Virtual Page Path to GATC-main tag.
6. Now let’s move from Tag Manager to Analytics and add two more Views to your web property. The default view will collect all metrics (main domain and third-level) whilst two more will be for each site separately.
6.1 You just have to create a new view, e.g. “Main site only” and Filter out all visits that starts with subfolder “/yoursiteonthirdlevel/”
6.2 For the other view “Third-level only” instead the FIlter has to include only subfolder starting with “/yoursiteonthirdlevel/” as shown above:
Done!
PROCEDURE FOR MULTIDOMAIN TRACKING The same procedure is valid also for multidomain tracking
- mysite1.xyz
- mysite2.xyz
- subdomain.myxite2.xyz
- etc.
CROSSDOMAIN Don’t forget to add also crossdomain tracking following the procedure suggested by Google to let cookies move across all your funnel. If you don’t take this step, you will not be able to measure campaign performance attributing value to each digital marketing channel. Good luck!
Thanks Paolo! Unfortunately that Google links appears to now be dead 🙁
I’m looking to track across multiple top level domains – do I need to modify the HTML anchors within my websites in any way to allow this to work?
Cheers, Ian
Thanks Paolo,
Is there any difference in using in GTM different containers for each subdomain and main domain. And filter the views in Analytics using “include only traffic to the hostname that contain nysubdomain.maindomain.com.au”?
Is there any implication, what are your thoughts?
Thanks again, cheers!
Azucena
Very helpful article. I don’t often leave comments, but this has helped me set up sub domain tracking on a website I have built.
Thanks for the post!
I don’t see the trusty “Virtual Page Path” in GTM V2. I assume you will select “page” under “Fields to Set” and then put the variable on the other side?