How to Track Information from Multiple Subdomains?

How to Track Information from Multiple Subdomains?

Many websites that exist on the Internet usually consist of a main domain and subdomains. Subdomains are part of the same top-level domain and contain information about different areas.

For example, “pogoda.gmail.com” and “tv.gmail.com” are subdomains of “gmail.com”. Therefore, when conducting web analytics, situations often arise where it is necessary to track information from several subdomains simultaneously.

Google Analytics uses only the main cookies to track information, i.e. the cookies of the domain being tracked. Since a subdomain has its own name, GA cannot track it automatically.

In other words, visitors who move between different subdomains of the same website cannot be tracked because only the main cookies are used.

Solution to the Problem

The situation can easily be resolved by making Google Analytics use the same cookies for all subdomains. To do this, simply call _setDomainName() and specify the name of the parent (main) domain.

For example, to track Google subdomains, “.google.com” should be specified as the argument.

Important: this solution is not suitable in all cases because the reports will not distinguish between pages with the same name on different subdomains. Additional filters are used for this purpose.

Configuring a Google Analytics Account for Multiple Subdomains

Option 1: Separate Profiles for the Domain and Subdomains

Creating a separate profile for each subdomain allows reports to be analyzed separately, which is especially important when promoting websites.  

The following data is recorded separately for each subdomain in the reports: search queries, time spent by a visitor on the website, number of unique visitors, traffic sources, etc.

Specific feature: transitions between subdomains are recorded as referral traffic. Implementation steps:

Implementation steps:

➤ Insert the current HTML code on the pages of one domain; ➤ Create a new profile in GA for the other domain and obtain a new HTML code; ➤ Insert the obtained code on the pages of the second domain.

As a result, we obtain two profiles with individual data for each domain.

Photo 1 - How to Track Information from Multiple Subdomains?

Option 2: One Profile for the Domain and Subdomains

In this case, all information from the domain and subdomains is collected in a single report, while visitor transitions are identified as transitions between pages of the same website.

Implementation steps:

➤ For asynchronous code, after _gaq.push(['_setAccount', 'UA-XXXXX-X']);, add _gaq.push(['_setDomainName', '.example.ua']); ➤ For standard code, after var pageTracker = _gat._getTracker("UA-XXXXXXX-XX");, add pageTracker._setDomainName(".example.ua");

Important: the domain must be specified with a dot at the beginning!

Filters:

➤ Create a custom filter with the “include” condition for each profile. ➤ Parameter: “Request URI”. ➤ In the filter field, enter: poddomen\.site\.ua.

Cross-Domain Tracking

Sometimes it becomes necessary to track information from several domains simultaneously within a single Google Analytics account. For example, the main range of products is located on one website (www.siteA.ua), while the order form is located on another (www.siteB.ua). As a rule, the main task is to track the effectiveness of these two web resources while keeping all the data in a single account.

Configuring the Code for Site A

Add the following to the GA code:

_gaq.push(['_setAllowLinker', true]); — enables cross-domain tracking. ➤ _gaq.push(['_setDomainName', 'siteA.ua']);

Add the functions onClick="_gaq.push(['_link', this.href]); return false;" and onSubmit="_gaq.push(['_linkByPost', this]);" to all links and forms leading from resource A to resource B.

Configuring the Code for Site B

Similarly:

_gaq.push(['_setAllowLinker', true]);_gaq.push(['_setDomainName', 'siteB.ua']);

The onClick and onSubmit functions are added to all forms and links leading from resource B to resource A.

Configuring the Filter in Google Analytics

To display the full website name in the reports:

➤ Filter type: “Custom” → “Advanced”. ➤ Field A: Hostname, Extract (.*). ➤ Field B: Request URI, Extract (.*). ➤ Output to: Request URI, Constructor $A1$B1.

After this, cross-domain tracking will work correctly.

Conclusion

With the correct configuration of cookies, profiles, and filters in Google Analytics, it becomes possible to effectively track the statistics of multiple subdomains and analyze data from different domains within a single account. This makes it possible to obtain a comprehensive picture of user behavior and their interaction with website resources. This approach significantly improves web analytics, allowing for a more accurate understanding of visitors’ needs and timely optimization of the website to increase conversions and the effectiveness of the online project.  

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.