다음은 동일한 Google 태그로 여러 도메인을 측정해야 하는 개발자를 위한 도움말입니다. 이 도움말에서는 gtag.js 코드 구현에 대해 중점적으로 설명합니다. GA4 속성의 Google 태그 설정에서 추가 도메인을 구성할 수도 있습니다.
교차 도메인 측정 기능을 사용하면 별도의 도메인에 있는 두 개 이상의 관련 사이트를 하나로 측정할 수 있습니다. Google 태그를 사용하면 고객 여정이 여러 도메인에 걸쳐 있는 경우 지원되는 제품에서 활동을 측정할 수 있습니다.
교차 도메인 측정은 Google 애널리틱스, Google Ads 전환 측정, 플러드라이트 전환을 비롯한 모든 Google 제품에서 작동합니다.
교차 도메인 측정을 구현해야 하는 경우
두 개 이상의 도메인에 대한 데이터를 결합해야 하는 경우 교차 도메인 측정을 구현하세요.
example-petstore.com에 웹사이트가 있고 웹사이트의 전자상거래 구성요소가
다른 도메인(example-commerce-host.com/example-petstore)에 있는 서드 파티 장바구니에서 호스팅된다고
가정해 보겠습니다.
교차 도메인 측정을 사용하지 않는 경우 온라인 상점을
방문한 다음 서드 파티 장바구니로 이동한 사용자는 기간이 서로
다른 두 개의 세션에서 활동한 두 명의 다른 사용자로 집계됩니다. 교차 도메인 측정을 사용하면 활동이 단일 사용자로 집계됩니다.
작동 방식
도메인 링커는 소스 도메인과 대상 도메인 간에 퍼스트 파티
측정 쿠키를 공유합니다. 퍼스트 파티 측정 쿠키는 웹브라우저에 저장되며
같은 도메인의 페이지에서만 액세스할 수 있습니다.
교차 도메인 측정 설정은 두 단계로 이루어집니다.
대상 도메인을 가리키는 URL이 소스 도메인의 퍼스트 파티 측정 쿠키 값을 포함하도록 소스 도메인에서 이 URL에 정보를 추가합니다.
연결된 측정 쿠키가 있는지 대상 도메인이 확인합니다.
Google 태그를 사용하는 교차 도메인 측정은 대상 도메인을 가리키는 URL에 링커 매개변수를 추가합니다. 링커 매개변수는 URL 쿼리 매개변수에서 _gl 키로 식별됩니다.
https://www.example.com/?_gl=1~abcde5~
대상 도메인에서 태그는 URL에 링커 매개변수가 있는지 확인하도록 구성됩니다. 유효한 링커 매개변수가 발견되면 태그가 퍼스트 파티 측정 쿠키를 추출하여 저장합니다.
교차 도메인 연결 설정
소스 도메인에서 대상 도메인을 가리키는 URL의 교차 도메인 측정을 설정하려면 linker 객체를 만들어야 합니다. 링커는 대상 도메인을
가리키는 링크의 클릭을 수신 대기하고 해당 링크의 URL에
링커 매개변수를 자동으로 추가합니다.
linker 객체에는 하나 이상의 도메인의 배열인 domains 매개변수가
필요합니다. 다음 코드는 대상 도메인인 'example.com'을 가리키는
페이지의 링크에 링커 도메인을 추가합니다.
gtag.js
Google 태그에 교차 도메인 측정을 설정하려면 다음과 같이 태그에 linker 명령어를 추가하세요. example.com을 내 도메인으로 바꾸세요.
domains 속성에 여러 문자열 값을 표시할 수 있습니다. domains 속성에 값이 한 개 이상 있으면 gtag.js는 기본적으로 수신 도메인 링크를 허용합니다. 여러 값을 domains 속성에 추가하고 모든 도메인에서 동일한 코드 스니펫을 사용할 수 있습니다.
linker 명령어가 관련된 config 명령어 앞에 설정되어 있으면 Google 애널리틱스 4가 gtag('set', 'linker', ...) 구성을 따릅니다.
하지만 Google 애널리틱스 4의 관리 페이지에서 교차 도메인 측정을 구성하는 것이 좋습니다. 교차 도메인 측정을 설정하는 방법 알아보기
accept_incoming은 Google 애널리틱스 설정 변수 또는 유니버설 애널리틱스 태그의 기타 설정 > 교차 도메인 추적에 있는 자동 링크 도메인 필드에 값을 추가하면 자동으로 설정됩니다.
url_position
일부 콘텐츠 애플리케이션에서는 일반적으로 사용되는 물음표 문자(?) 대신 프래그먼트/해시 문자(#)를 URL 문자열에서 구분 기호로 사용하여 쿼리 매개변수를 표시해야 합니다. URL에서 # 문자(예: https://example.com#_gl=1~abcde5~)
뒤에 표시되도록 링커 매개변수를
구성하려면 url_position을 fragment로 설정합니다.
[null,null,["최종 업데이트: 2024-02-06(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,["# Measure activity across multiple domains\n\n\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------------------------------------------\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------------\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---------------------------\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\n### gtag.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\n### Tag Manager\n\n### For 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\n### For 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\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\n### gtag.js\n\n gtag('set', 'linker', {\n 'accept_incoming': true\n });\n\n### Tag Manager\n\n#### Conversion 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\n### gtag.js\n\n gtag('set', 'linker', {\n 'domains': ['example.com'],\n 'decorate_forms': true\n });\n\n### Tag Manager\n\n#### Conversion Linker tags for Google Ads and Floodlight conversions\n\nSet **Decorate Forms** to *true*.\n\n#### Google 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\n### gtag.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\n### Tag Manager\n\n#### Conversion 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\n#### Google 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\n### gtag.js\n\n gtag('set', 'linker', {\n 'domains': ['example.com'],\n 'decorate_forms': true,\n 'url_position': 'fragment'\n });\n\n### Tag Manager\n\n#### Conversion 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."]]