{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Products","product_name":"Integration Hub","type":"markdown"},"seo":{"title":"Known Visitor Ids With JavaScript SDK","description":"Learn how to add and track known visitor IDs like email and user ID using Treasure AI's JavaScript SDK with cross-domain tracking and optional encryption.","siteUrl":"https://docs.treasure.ai","lang":"en-US","jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.treasure.ai/","name":"Treasure AI","url":"https://www.treasure.ai/","logo":"https://www.treasure.ai/hubfs/assets/images/logos/primary-logo.svg"},{"@type":"WebSite","@id":"https://docs.treasure.ai/#website","name":"Treasure AI Documentation","url":"https://docs.treasure.ai/","inLanguage":["en","ja"],"publisher":{"@id":"https://www.treasure.ai/"}}]},"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":"known-visitor-ids-with-javascript-sdk","__idx":0},"children":["Known Visitor Ids With JavaScript SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can add known ids of visitors with Treasure Data SDKs."]},{"$$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 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-integrations/google-tag-manager-import-integration"},"children":["Treasure Data JavaScript SDK"]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"adding-known-ids-for-website-tracking","__idx":2},"children":["Adding Known IDs for Website Tracking"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To add known IDs of visitors (most commonly, email, user_id, etc):"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["td.set()"]}," function can be used to add an arbitrary number of additional information for the visitors."]},{"$$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  // Enable cross-domain tracking\n  td.set('$global', 'td_global_id', 'td_global_id');\n\n  // Add Known IDs to tracking information\n  td.set('pageviews', {\n    email: 'kazuki@treasure-data.com',\n    account_id: '1024'\n  });\n\n  // Track pageview information to 'pageviews' table\n  td.trackPageview('pageviews');\n</script>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["As Treasure Data is schema-less architecture, you can add and subtract any number of known ID columns anytime."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"encrypting-knownids-with-cryptojs","__idx":3},"children":["Encrypting KnownIDs with CryptoJS"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You might want to send raw known IDs to Treasure Data. CryptoJS supports the majority of encryption algorithms including SHA-256, AES, etc.:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Apply encryption with ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/brix/crypto-js"},"children":["CryptoJS"]},", before sending IDs to Treasure Data."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<!-- Load CryptoJS library -->\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js\"></script>\n<script type=\"text/javascript\">\n  ....\n  // Add Known IDs to tracking information\n  td.set('pageviews', {\n    email: CryptoJS.enc.Base64.stringify(CryptoJS.SHA256('meg@tre-data.com')),\n    account_id: CryptoJS.enc.Base64.stringify(CryptoJS.AES.encrypt('1024', 'secret key 1234').ciphertext)\n  });\n  ....\n</script>\n","lang":"html"},"children":[]}]},"headings":[{"value":"Known Visitor Ids With JavaScript SDK","id":"known-visitor-ids-with-javascript-sdk","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Adding Known IDs for Website Tracking","id":"adding-known-ids-for-website-tracking","depth":2},{"value":"Encrypting KnownIDs with CryptoJS","id":"encrypting-knownids-with-cryptojs","depth":2}],"frontmatter":{"seo":{"title":"Known Visitor Ids With JavaScript SDK","description":"Learn how to add and track known visitor IDs like email and user ID using Treasure AI's JavaScript SDK with cross-domain tracking and optional encryption."}},"lastModified":"2026-06-17T07:22:53.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/known-visitor-ids-with-javascript-sdk","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}