How To Setup Subdomain Tracking



By  September 22nd, 2016









ga-subdomain-tracking


Google Analytics is configured to record visitor traffic only for a single domain. This is the default setup.


This means that when a visitor reaches a website — example.com — for the first time, Google Analytics records it as a new session from a new user.


But if that visitor travels travels to and from the site’s subdomains — blog.example.com, support.example.com — Google starts a new session for the same user, and it lists the other part of the domain as the referral site.


This causes problems when you want to track the number of visitors and the number of sessions for your whole site, subdomains included.


Fortunately, site owners can change this behavior by following a set of simple steps.


Classic Google Analytics


With Classic Google Analytics there is a need to alter the tracking script to enable subdomain tracking.


Consider a site, example.com, with 2 subdomains; blog.example and support.example.com


The site owner would make this simple change to the tracking code:



  • Asynchronous Syntax









1 <script>






2 var _gaq = _gaq || [];






3 _gaq.push([‘_setAccount’, ‘UA-12345-1’]);






4 _gaq.push([‘_setDomainName’, ‘example.com’]);






5 _gaq.push([‘_trackPageview’]);






6 ></script>


  • Traditional Syntax









1 <script>






2 var pageTracker = _gat._getTracker(‘UA-12345-1’);






3 pageTracker._setDomainName(‘example.com’);






4 pageTracker._trackPageview();

Google Tag Manager


If your analytics is implemented via Google Tag Manager, go back into that tag and set ‘cookieDomain’ to auto.


Universal Analytics


The tracking code from Universal Analytics is already completely set to track subdomains. BUT — you absolutely need to verify, and perhaps update, the Referral Exclusion List or Google Analytics will start a new sessions when switching between the subdomains.


The “Referral Exclusion List” can be accessed through the following path:


Admin -> Property -> Tracking Info -> Referral Exclusion List


Once there ensure the main, top-level domain is listed there: example.com in our case.


If it’s not there, click Add Referral Exclusion and add the domain.


image


 


Optional: Filters


See Domain Name In Report


Google Analytics displays URLs without the domain name in its tracking list. This can make it hard to easily see if /page1.html was accessed on example.com, blog.example.com, or support.example.com


This can be fixed by adding a filter to the view:



  • Filters -> Add New Filter -> Custom ->Advanced
  • Choose ‘Hostname’ for Field A and enter (.*) in the field space
  • Now select ‘Request URL’ for Field B and again enter (.*)

In the third step, choose ‘Request for URL’ for Field C and enter the value $A1B1


SNAGHTML1081f815


Reporting On (Sub)domains Separately


If you want to be able to see reports for each domain and subdomain separately, you have to create views for each and one for all combined.


In our case of example.com, blog.example.com, and support.example.com we would have 4 views:



  1. All Traffic Combined
  2. example.com
  3. blog.example.com
  4. support.example.com

For each domain specific view you have to create inclusion filters that remove all traffic from the other domains.


Go to Filters -> Add New Filter -> Custom -> Include -> Hostname


For the main domain, example.com, we would enter:


image


When the blog.example.com view is selected we would enter:


image


Hand-Picked Related Articles:



* Adapted lead image:  Public Domain, pixabay.com via getstencil.com




 




About the Author:






Martin Brown is the Marketing Executive of Top SEO Rankers based in New York. Top SEO Rankers evaluates and lists the top Digital Marketing firms and also gives SEO service providers a direct channel for prospective leads to find them.

Top SEO Rankers



How To Setup Subdomain Tracking

The post How To Setup Subdomain Tracking appeared first on Search Engine People Blog.

Engine People Blog

(113)