To measure activity when your customer journeys span two or more related sites across multiple domains, add the domain linker to your Google tags.
- An online retailer has country-specific stores, but it also has a single site for processing purchases.
- A customer visits example.store.co.uk, clicks the purchase button in the shopping cart, and is sent to the example.store.com domain to complete the transaction.
- To link the conversion on example.store.com to the visit on example.store.co.uk, the retailer adds the domain linker to the Google tags on both sites.
The domain linker shares first-party measurement cookies between your source domain and your destination domain. The first-party measurement cookies are stored in a web browser, and only pages on the same domain can access them.
How to use the domain linker
To use the domain linker, do the following:
- Add
gtag('set', 'linker' {domains})
to your Google tags. - Add the command to all pages in your source domain that can send visitors to your destination domain.
- Specify the destination domain in the command's domains property as follows:
gtag('set', 'linker', {
'domains': ['destination-domain.com']
});
To streamline tag maintenance, consider adding the command to all pages on your sites and listing all of your domains in the command's domains property. This enables you to use the same command on all of your pages and ensures that conversions can be properly measured regardless of the direction of links across your sites.
Using the online retailer example, the following is a Google tag with a set linker
command (highlighted below) that names both domains:
<!--
Start of global snippet: Please do not remove
Place this snippet between the <head> and </head> tags on every page of your site.
-->
<!-- Google tag (gtag.js) - DoubleClick -->
<script async src="https://www.googletagmanager.com/gtag/js?id=DC-1234567"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('set', 'linker', {
'domains': ['example.store.co.uk', 'example.store.com']
});
gtag('js', new Date());
gtag('config', 'DC-1234567');
</script>
<!-- End of global snippet: Please do not remove -->
To ensure that set
values are available for config
commands and available to any dynamically loaded containers, add the set
command above the js
command in your Google tag.
What does the set linker command do?
The gtag('set', 'linker' {domains})
command adds a URL parameter named _gl
to URLs on the page that points to a domain listed in the command. When the Google tag on the destination page sees this URL parameter, it extracts the first-party measurement cookie and stores it. The first-party measurement cookie is shared between your source domain and your conversion domain.
- The
gtag('set', 'linker' {domains})
command on the shopping cart page adds the_gl
parameter to the URL that points to the conversion domain:
https://example.store.com/purchase/?_gl=1~abcde5~
- When the link reaches https://example.store.com/purchase, the Google tag on the page extracts the first-party measurement cookie and stores it.
Learn more about measuring customer journeys across domains.