Tracking Goals with Subdomains in Google Analytics


Last updated: July 16, 2019

Introduction

Sometimes your conversion funnel spans multiple domains or subdomains. If you need to track destination url goals on a subdomain for an existing universal analytics property, you can follow the steps below to distinguish between root domain visitors and subdomain visitors along with goals that might have the same url path. This is not to be confused with cross-domain tracking which requires different configuration settings.

Add the universal analytics tracking code from your root domain to your subdomain and ensure that the cookie domain is set to auto (by default it is set in universal analytics unless you are using GTM).

Step 2 - Add a referral exclusion list

Add your subdomain to the referral exclusion list. That way, Google doesn’t set the referrer as your subdomain when your visitors jump between your root domain and subdomain, when it should be set to the originating source like an ad or search.

Step 3 - Add a filter to your GA view

Add a subdomain filter to your view. Since the most common goals are destination goals and Google Analytics utilizes the Request URI (path) as the match value, we need to distinguish between subdomain paths and root domain paths. Google by default only matches against the path information so we need to modify the path data to include the subdomain in our filter.

You want to select the advanced filter and extract the hostname (your subdomain) and concatenate it with the request uri (your path), and store it as the new path. In the example below we only do this for subdomains. You could do this for every path shown here .

Step 4 - Set goals

Set up your goals with the destination path if you have the default requrest uri set, or with the hostname included if your filter is set up that way. See the examples below for a path only set up for the root domain and a hostname and path set up for the subdomain.

Notice that they share the same path and Google Analytics would have counted them as the same goal if we did not explicitly make that distinction in our filtered view.

Step 5 - Set autolinker (for cross domain only)

If you have a different domain but want to track it under the same property, you need to configure Google Analytics to allow linker like so:

  ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['example-2.com']);

In Google Tag Manager you will need to set the Field Name of Fields to Set add “allowLinker” as the Field Name and set the Value to “true”. Under Cross Domain Tracking, add a comma separated list of domains that you want to share the client id under the Auto Link Domains field.

Conclusion

There you have it. Now you’re ready to start tracking across multiple subdomains. If you need help tracking your goals across multiple domains or subdomains to collect analytics for your leads request a consultation today!


Recent Blog Posts