Stay organized with collections
Save and categorize content based on your preferences.
This article is for developers who need to measure multiple domains with the
same Google tag. This article focuses on a gtag.js code implementation. You
can also configure additional domains in your Google tag settings
of your GA4 property.
Cross-domain measurement enables two or more related sites on separate domains
to be measured as one. Google tags provide a common way for supported products
to measure activity when your customer journeys span across multiple domains.
Cross-domain measurement works for all Google products, including Google
Analytics, Google Ads conversion measurement, and Floodlight conversions.
When to implement cross-domain measurement
Implement cross-domain measurement when you need to combine data for two or more
domains.
Suppose you have a website at example-petstore.com, and your website's
ecommerce component is hosted by a third-party shopping cart on another domain:
example-commerce-host.com/example-petstore.
Without cross-domain measurement, a user who arrives to your online store and
then proceeds to your third-party shopping cart is counted as two separate
users, with two separate sessions of different durations. With cross-domain
measurement, activity is captured as a single user.
How it works
The domain linker shares first-party measurement cookies between a source domain
and a destination domain. The first-party measurement cookies are stored in a
web browser, and can only be accessed by pages on the same domain.
Setup for cross-domain measurement is a two-step process:
The source domain decorates URLs that point to the destination domain so
that they contain the first-party measurement cookie values of the source
domain.
The destination domain checks for the presence of linked measurement
cookies.
Cross-domain measurement with Google tags will add a linker parameter to URLs
that point to the destination domain. The linker parameter is identified in URL
query parameters with the key _gl:
https://www.example.com/?_gl=1~abcde5~
On the destination domain, tags are configured to check for linker parameters in
the URL. If a valid linker parameter is found, the tag extracts the first-party
measurement cookie and stores it.
Set up cross-domain linking
To set up cross-domain measurement on the source domain for URLs that point to
the destination domain, you need to create a linker object. The linker will
listen for clicks on links that point to destination domains, and it will
automatically add a linker parameter to the URLs of those links.
The linker object requires a domains parameter, which is an array of one or
more domains. This code will append the linker parameter to links on a page that
points to a target domain 'example.com':
gtag.js
To set up cross-domain measurement for the Google tag, add a linker
command to your tag as follows. Replace example.com with your domain.
You can list multiple string values in the domains property. When the
domains property has at least one value, gtag.js will accept incoming
domain links by default. You can add several values to the domains propety
and use the same code snippet on every domain.
Google Analytics 4 honors gtag('set', 'linker', ...) configurations, so
long as the linker command is set before the relevant config command.
However, we recommend configuring cross-domain measurement on the Admin page
of Google Analytics 4. Learn how to set up cross domain
measurement
In Tag Manager, create a Conversion Linker tag and then set the tag to
auto-link domains.
Click Tags > New.
Click Tag Configuration and select Conversion Linker.
Select a trigger. In most cases, you should use a trigger that fires on
all page views for cross domain measurement, or on specific conversion
pages where site visitors will land after an ad is clicked.
Select Enable linking across domains. This setting will enable this
tag to handle incoming links that have a linker parameter.
In Auto Link Domains, enter a list of domains that should be linked
with this tag. Any links that point to a domain listed in this field
will have a linker parameter appended to the URL.
In the Auto Link Domains field, enter a comma-separated list of
domains.
To receive incoming links from other domains, navigate to More
Settings > Fields to Set and add a field with a Field Name of
allowLinker and a Value of true.
Once a user arrives at a page on the destination domain with a linker parameter
in the URL, your tags need to be configured to parse that parameter.
If the destination domain has been configured to automatically link domains, it
will accept linker parameters by default. No additional code is required on the
destination domain.
If the destination domain is not configured to automatically link domains, you
can instruct the destination page to look for linker parameters. Set the
accept_incoming property to true.
gtag.js
gtag('set','linker',{'accept_incoming':true});
Tag Manager
Conversion Linker tags for Google Ads and Floodlight conversions
Activate the Accept incoming linker parameters checkbox.
decorate_forms
To measure form data that is sent between multiple domains, set the
decorate_forms property to true.
Conversion Linker tags for Google Ads and Floodlight conversions
Select Enable linking across domains
In the Auto Link Domains field, enter a list of domains separated by
commas.
Google Analytics 4
Set up cross domain measurement via the Admin pages in Google Analytics.
url_position
Certain content applications require you to use a fragment/hash character (#)
as the delimiter in URL strings instead of the more commonly used question mark
character (?) to indicate query parameters. To configure the linker parameter
to appear in the URL after a # character (e.g.
https://example.com#_gl=1~abcde5~), set url_position to fragment.
Conversion Linker tags for Google Ads and Floodlight conversions
If you need to tell Tag Manager to read the unique parameter from a fragment
(#) instead of a standard query (?), set URL Position to Fragment.
Otherwise, leave this option set to the default Query Parameter option.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-14 UTC."],[[["\u003cp\u003eThis guide explains how to implement cross-domain measurement with Google tags (gtag.js) to track user journeys across multiple related websites as a single user.\u003c/p\u003e\n"],["\u003cp\u003eCross-domain measurement is essential when you need to consolidate data from two or more domains, such as an online store and a separate shopping cart domain.\u003c/p\u003e\n"],["\u003cp\u003eIt works by sharing first-party measurement cookies between domains using a linker parameter appended to URLs, enabling unified user tracking.\u003c/p\u003e\n"],["\u003cp\u003eSetup involves creating a \u003ccode\u003elinker\u003c/code\u003e object in gtag.js or using the Conversion Linker tag in Google Tag Manager, specifying the linked domains.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Analytics 4 users should preferably configure cross-domain measurement through the Admin interface instead of directly through tags.\u003c/p\u003e\n"]]],["Cross-domain measurement combines data from multiple domains into a single user journey. Implementation involves setting up a `linker` object on the source domain to append a linker parameter (`_gl`) to URLs leading to destination domains. This allows first-party cookie sharing. In gtag.js, use `gtag('set', 'linker', {'domains': [...]})` to specify domains. Tag Manager requires configuring a Conversion Linker tag and enabling auto-linking. The destination domain must be configured to accept incoming linker parameters, either automatically or by setting `accept_incoming` to true.\n"],null,["\u003e This article is for developers who need to measure multiple domains with the\n\u003e same Google tag. This article focuses on a gtag.js code implementation. You\n\u003e can also configure additional domains in your [Google tag settings](https://support.google.com/tagmanager/answer/12131703#Domains&zippy=%2Cconfigure-your-domains)\n\u003e of your GA4 property.\n\nCross-domain measurement enables two or more related sites on separate domains\nto be measured as one. Google tags provide a common way for supported products\nto measure activity when your customer journeys span across multiple domains.\nCross-domain measurement works for all Google products, including Google\nAnalytics, Google Ads conversion measurement, and Floodlight conversions.\n\nWhen to implement cross-domain measurement\n\nImplement cross-domain measurement when you need to combine data for two or more\ndomains.\n\nSuppose you have a website at `example-petstore.com`, and your website's\necommerce component is hosted by a third-party shopping cart on another domain:\n`example-commerce-host.com/example-petstore`.\n\n*Without* cross-domain measurement, a user who arrives to your online store and\nthen proceeds to your third-party shopping cart is counted as two separate\nusers, with two separate sessions of different durations. *With* cross-domain\nmeasurement, activity is captured as a single user.\n\nHow it works\n\nThe domain linker shares first-party measurement cookies between a source domain\nand a destination domain. The first-party measurement cookies are stored in a\nweb browser, and can only be accessed by pages on the same domain.\n\nSetup for cross-domain measurement is a two-step process:\n\n1. The source domain decorates URLs that point to the destination domain so that they contain the first-party measurement cookie values of the source domain.\n2. The destination domain checks for the presence of linked measurement cookies.\n\nCross-domain measurement with Google tags will add a linker parameter to URLs\nthat point to the destination domain. The linker parameter is identified in URL\nquery parameters with the key `_gl`: \n\n https://www.example.com/?_gl=1~abcde5~\n\nOn the destination domain, tags are configured to check for linker parameters in\nthe URL. If a valid linker parameter is found, the tag extracts the first-party\nmeasurement cookie and stores it.\n\nSet up cross-domain linking\n\nTo set up cross-domain measurement on the source domain for URLs that point to\nthe destination domain, you need to create a `linker` object. The linker will\nlisten for clicks on links that point to destination domains, and it will\nautomatically add a linker parameter to the URLs of those links.\n| **Note:** Linker parameters expire after two minutes, so the linker parameter is only added at the time of the click event.\n\nThe `linker` object requires a `domains` parameter, which is an array of one or\nmore domains. This code will append the linker parameter to links on a page that\npoints to a target domain *'example.com'*: \n\ngtag.js\n\nTo set up cross-domain measurement for the Google tag, add a `linker`\ncommand to your tag as follows. Replace `example.com` with your domain.\n**Note:** To ensure `set` values are available for `config` commands and available to any dynamically loaded containers, add the `set` commands above the `js` command. \n\n \u003cscript async src=\"https://www.googletagmanager.com/gtag/js?id=TAG_ID\"\u003e\u003c/script\u003e\n \u003cscript\u003e\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('set', 'linker', {'domains': \\['example.com'\\]});\n gtag('js', new Date());\n\n gtag('config', 'TAG_ID');\n \u003c/script\u003e\n\nYou can list multiple string values in the `domains` property. When the\n`domains` property has at least one value, gtag.js will accept incoming\ndomain links by default. You can add several values to the `domains` propety\nand use the same code snippet on every domain.\n\nGoogle Analytics 4 honors `gtag('set', 'linker', ...)` configurations, so\nlong as the `linker` command is set before the relevant `config` command.\nHowever, we recommend configuring cross-domain measurement on the Admin page\nof Google Analytics 4. [Learn how to set up cross domain\nmeasurement](https://support.google.com/analytics/answer/10071811#setup) \n\n gtag('set', 'linker', {\n 'domains': \\['example.com', 'example-b.com'\\]\n });\n\n| **Note:** The Google tag will match against any link with a hostname that contains a value found in the `domains` array.\n\nTag Manager\n\nFor Google Ads and Floodlight tags\n\nIn Tag Manager, create a **Conversion Linker** tag and then set the tag to\nauto-link domains.\n\n1. Click **Tags \\\u003e New**.\n2. Click **Tag Configuration** and select **Conversion Linker**.\n3. Select a trigger. In most cases, you should use a trigger that fires on all page views for cross domain measurement, or on specific conversion pages where site visitors will land after an ad is clicked.\n4. Select **Enable linking across domains**. This setting will enable this tag to handle incoming links that have a linker parameter.\n5. In **Auto Link Domains**, enter a list of domains that should be linked with this tag. Any links that point to a domain listed in this field will have a linker parameter appended to the URL.\n6. Save and publish your tag configuration.\n\n[Learn more about Tag Manager's Conversion Linker](https://support.google.com/tagmanager/answer/7549390)\n\nFor Google Analytics 4 tags\n\nIn Google Analytics 4, cross-domain measurement is configured via the Google\nAnalytics Admin interface. [Learn how to set up cross domain measurement\nwith Google Analytics 4](https://support.google.com/analytics/answer/10071811).\n| **Note:** The preferred method is to make changes to the Google Analytics Settings variable, so that changes are shared across multiple tags.\n\n1. In the **Auto Link Domains** field, enter a comma-separated list of domains.\n2. To receive incoming links from other domains, navigate to **More\n Settings \\\u003e Fields to Set** and add a field with a Field Name of *allowLinker* and a **Value** of *true*.\n3. Save your changes and publish the container.\n\nLinker parameter reference\n\n| Parameter | Type | Accepted values |\n|---------------------------------------|---------|--------------------------------------------------------------------------|\n| [`accept_incoming`](#accept_incoming) | boolean | `true` (default if `domains` has value), `false` |\n| [`decorate_forms`](#decorate_forms) | boolean | `true`, **`false`** (default) |\n| [`domains`](#domains) | array | An array of one or more domains, e.g. `['example1.com', 'example2.com']` |\n| [`url_position`](#url_position) | string | `'query'` (default), `'fragment'` |\n\n`accept_incoming`\n\nOnce a user arrives at a page on the destination domain with a linker parameter\nin the URL, your tags need to be configured to parse that parameter.\n\nIf the destination domain has been configured to automatically link domains, it\nwill accept linker parameters by default. No additional code is required on the\ndestination domain.\n\nIf the destination domain is *not* configured to automatically link domains, you\ncan instruct the destination page to look for linker parameters. Set the\n`accept_incoming` property to `true`. \n\ngtag.js \n\n gtag('set', 'linker', {\n 'accept_incoming': true\n });\n\nTag Manager\n\nConversion Linker tags for Google Ads and Floodlight conversions\n\nActivate the **Accept incoming linker parameters** checkbox.\n\n`decorate_forms`\n\nTo measure form data that is sent between multiple domains, set the\n`decorate_forms` property to `true`. \n\ngtag.js \n\n gtag('set', 'linker', {\n 'domains': ['example.com'],\n 'decorate_forms': true\n });\n\nTag Manager\n\nConversion Linker tags for Google Ads and Floodlight conversions\n\nSet **Decorate Forms** to *true*.\n\nGoogle Analytics 4 tags\n\nThere is no control for `decorate_forms` for Google Analytics tags in Tag\nManager. Refer to the gtag.js guidance instead.\n\n`domains`\n\nAn array of one or more domains to be linked. \n\ngtag.js \n\n gtag('set', 'linker', {\n 'domains': \\[\n 'example1.com',\n 'example2.com',\n 'subdomain1.example3.com',\n 'subdomain2.example3.com'\n \\]\n });\n\nTag Manager\n\nConversion Linker tags for Google Ads and Floodlight conversions\n\n1. Select *Enable linking across domains*\n2. In the Auto Link Domains field, enter a list of domains separated by commas.\n\nGoogle Analytics 4\n\nSet up cross domain measurement via the [Admin](https://support.google.com/analytics/answer/10071811) pages in Google Analytics.\n\n`url_position`\n\nCertain content applications require you to use a fragment/hash character (`#`)\nas the delimiter in URL strings instead of the more commonly used question mark\ncharacter (`?`) to indicate query parameters. To configure the linker parameter\nto appear in the URL after a `#` character (e.g.\n`https://example.com#_gl=1~abcde5~`), set `url_position` to `fragment`. \n\ngtag.js \n\n gtag('set', 'linker', {\n 'domains': ['example.com'],\n 'decorate_forms': true,\n 'url_position': 'fragment'\n });\n\nTag Manager\n\nConversion Linker tags for Google Ads and Floodlight conversions\n\nIf you need to tell Tag Manager to read the unique parameter from a fragment\n(`#`) instead of a standard query (`?`), set **URL Position** to *Fragment* .\nOtherwise, leave this option set to the default *Query Parameter* option."]]