{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"redocly_category":"Products","product_name":"Integration Hub","type":"markdown"},"seo":{"title":"Enabling Cross Domain Tracking With JavaScript SDK","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"enabling-cross-domain-tracking-with-javascript-sdk","__idx":0},"children":["Enabling Cross Domain Tracking With JavaScript SDK"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data recommends that you implement any new features or functionality at your site using the Treasure Data JavaScript SDK version 3. It manages cookies differently. Be aware when referring to most of these articles that you need to define the suggested event collectors and Treasure Data JavaScript SDK version 3 calls in your solutions."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Basic knowledge of JavaScript and HTML"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Basic knowledge of Treasure Data"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Basic knowledge of Treasure Data JavaScript SDK"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You need at least JavaScript SDK v1.7.1"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Validate that you want to track 3rd party cookies from web browsers that allow them"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"limitations","__idx":2},"children":["Limitations"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data’s Cross Domain Tracking relies on 3rd party cookie mechanism. For more details, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/anonymous-visitor-ids-with-javascript-sdk"},"children":["Anonymous IDs"]},". It’s particularly important to understand the limitation of 3rd party cookies because it doesn’t work for Mobile and PC Safari browsers."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"enabling-cross-domain-tracking","__idx":3},"children":["Enabling Cross-Domain Tracking"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Cross-Domain tracking must be enabled to be active for ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/quickstart"},"children":["JavaScript SDK"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Call ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["td.set('$global', 'td_global_id', 'td_global_id');"]}," to enable the feature."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<script type=\"text/javascript\">\n  // Configure an instance for your database\n  var td = new Treasure({\n    host: 'in.treasuredata.com',\n    writeKey: 'YOUR_WRITE_ONLY_APIKEY_IS_HERE',\n    database: 'DATABASE_NAME'\n  });\n  // Enable cross-domain tracking\n  td.set('$global', 'td_global_id', 'td_global_id');\n  // Track pageview information to 'pageviews' table\n  td.trackPageview('pageviews');\n</script>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This line adds an additional column called ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["td_global_id"]}," to the destination table."]}]},"headings":[{"value":"Enabling Cross Domain Tracking With JavaScript SDK","id":"enabling-cross-domain-tracking-with-javascript-sdk","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Limitations","id":"limitations","depth":2},{"value":"Enabling Cross-Domain Tracking","id":"enabling-cross-domain-tracking","depth":2}],"frontmatter":{"seo":{"title":"Enabling Cross Domain Tracking With JavaScript SDK"}},"lastModified":"2026-05-14T07:31:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/enabling-cross-domain-tracking-with-javascript-sdk","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}