Google Analytics Multi-Domain Management

Master seamless tracking across multiple domains with Google Analytics best practices and unified data insights.

Ceyhun Enki Aksan
Ceyhun Enki Aksan Entrepreneur, Maker

In certain projects, the microsites included in the project content may have been set up by different decision-makers. In such processes, centralizing data and interpreting user data collected from various environments to achieve more meaningful outcomes can also introduce additional complexities.

Authorization issues, inability to access pre-deployment data, the need to integrate segmentation across different ad accounts, and other adverse situations can result in serious consequences if the process is poorly planned from the outset—especially if no strategy is developed at all. In this article, I will discuss a situation that may prove useful to you in scenarios where authorization is held by different agencies or individuals, or when multiple websites are centralized under a single campaign: using a single Google Analytics account for multiple domains.

tip

You can find support requests related to Google Analytics here.

Multi-Domain Google Analytics Setup

Certainly, in a situation where such requirements exist, we recommend a feature you should consider. Your priority should be to keep data as lean and simple as possible, unless absolutely necessary. We know that Google Analytics creates a tracking identity based on a domain (property ID). Therefore, we must first designate a primary domain. Once the primary domain is defined, the created Account meets the basic requirements by including a Property and a standard View. After this stage, the process will proceed with the JavaScript-based tracking code required by Google Analytics to complete the installation and transfer data.

Google Analytics
Google Analytics

analytics.js

The analytics.js library primarily provides a basic setup involving the property ID and the page view being sent to that ID1.

ga('create', 'UA-101596151-1', 'auto');
ga('send', 'pageview');

We can achieve cross-domain tracking using the linker plugin in a multi-domain setup2. It’s important to remember that multi-domain tracking is achieved through a primary domain with a unique property ID, and additional domains that are redirected to this primary domain.

// Enable the linker for the relevant property
ga('create', 'UA-XXXXX-Y', 'auto', {allowLinker: true});

// Load the plugin
ga('require', 'linker');

// Add the linker parameter to ensure that all links and forms pointing to the domain "destination.com" are sent to destination.com.
// For all links and forms pointing to the domain "destination.com"
ga('linker:autoLink', ['source.com', 'destination.com']);

The false and true values in this line serve as toggles for form and tracking configuration2. When implementing multi-domain tracking via the Tag Manager, you must specify the relevant fields as either false or true. In accordance with the Global Site Tag structure, the configuration would be as follows.

gtag('config', 'UA-XXXXX-Y', {
  linker: {
    accept_incoming: true,
    domains: ['destination.com']
  }
});
gaCrossDomains
gaCrossDomains

Google Tag Manager

Within Google Tag Manager, we need to specify domains when setting up the Google Analytics tag3. In the next step, we will define the specified domains within Google Analytics AutoLink4. We then re-enable the AllowLinker and define the primary domain for cookies. After these actions, you can verify the setup through the Preview mode. Finally, we must apply filtering under Google Analytics > Property > View > Filters (or directly to all properties via Account > All Filters). This way, we can clearly display the primary machine name values in our reports.

Google Analytics
Google Analytics

The steps we need to follow are: Filter Type > Custom > Advanced. Then, for the A Field -> A Output, we define the “Primary Machine Name” option in the format (.*) (see joker characters). We apply the same value to the B Field -> B Output for the “Request URI” option. Afterward, for the Output Target -> Processor, we can use the $A1$B1 value to reflect both A and B fields into our reports. In summary, you can also verify these steps via the following visual guide.

Footnotes

  1. analytics.js Cross-domain measurement. Google Analytics
  2. Linker. Google Analytics 2
  3. Measure activity across domains. Google Tag Manager Help
  4. Tom Capper. (2014). How to Quickly (and Correctly) Track Google Analytics Across Multiple Domains. MOZ