Use the Google tag
Cross-domain conversion tracking
To measure activity when your customer journeys span two or more related sites across multiple domains, add the domain linker to your Google tags.
For example:
- An online retailer has country-specific stores but 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 1st party measurement cookies between your source domain and your destination domain. The 1st party measurement cookies are stored in a web browser, and can only be accessed by pages on the same domain.
On this page
How to use the domain linker
To use the domain linker, 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, and specify the destination domain in the command's domains property:
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.
Continuing the example of the online retailer, here's a Google tag with a set linker command 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 -->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 point to a domain listed in the command. When the Google tag on the destination page update this URL parameter, it extracts the 1st party measurement cookie and stores it, which shares the 1st party measurement cookie between your source domain and your conversion domain.
Continuing the example of the online retailer:
- The
gtag('set', 'linker' {domains})command on the shopping cart page adds the_glparameter to the URL that points to the conversion domain:
https://example.store.com/purchase/?_gl=1~abcde5~ - When the link reacheshttps://example.store.com/purchase, the Google tag on that page extracts the 1st party measurement cookie and stores it.
Learn more about measuring customer journeys across domains.
