{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"WebサイトでのServer-Side First Party Cookieのtracking","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":"webサイトでのserver-side-first-party-cookieのtracking","__idx":0},"children":["WebサイトでのServer-Side First Party Cookieのtracking"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ウェブサイト上のユーザーを識別して追跡するには、server-side first party cookieを使用します。Treasure DataのJavaScript SDKを通じてfirst party、server-side cookieを作成して収集できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ウェブサイトでユーザーデータを収集するフローは次のとおりです:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーがウェブサイトにアクセスします。Treasure Dataは、ユーザー用のtd_ssc_id cookieが存在するかどうかを確認します。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["存在する場合、ウェブサイトにインストールされているTreasure Data SDKを通じてアクティビティが追跡されます"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["存在せず、consentが許可されている場合、Treasure Data SDKはユーザー用にfirst party、server-side cookieを作成します"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataはユーザーのconsent responseを記録します。Treasure Data SDKの設定で、ユーザーconsentが保存される場所を指定します。ユーザーのbrowserにconsentを保存することで、ウェブサイトにアクセスするたびにtrackingの許可を求められることがなく、consent recordはウェブサイトのcookieドキュメントで指定されたとおりに永続化されます。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーがtrackingの許可を付与します。webページ上のTreasure APIがTreasure Dataに一意のIDをrequestします。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataがwebページに一意のIDを送り返します。Server-side cookieは最大2年間永続化するように設定できます。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーのtd_ssc_idはウェブサイトのcookieドキュメントに保存され、Treasure Data SDKで設定されている場合、ユーザーが実行したアクティビティの追跡がCDPアカウントに記録されます。"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["first party cookieのserver-side trackingを有効にするには、以下のセクションを完了します:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#prerequisites"},"children":["前提条件"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#known-limitation"},"children":["既知の制限事項"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#setting-up-the-ns-record-in-your-dns"},"children":["DNSでのNS Recordのセットアップ"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#configuring-the-js-sdk-to-collect-and-store-first-party-cookies"},"children":["First Party Cookieを収集して保存するためのJS SDKの設定"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#treasure-data-javascript-sdk-overview-and-installation"},"children":["Treasure Data JavaScript SDKの概要とインストール"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#embed-the-js-code-to-call-the-server-side-cookie"},"children":["Server Side Cookieを呼び出すJSコードの埋め込み"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#modify-your-existing-js-sdk-to-establish-a-connection"},"children":["接続を確立するための既存のJS SDKの変更"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website#specifying-the-consent-record-location"},"children":["Consent Record locationの指定"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この機能のセットアップには、HTMLとJavaScriptでの設定方法を知っている必要があります。さらに、以下が必要です:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataの基礎知識"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data JavaScript SDKの基礎知識"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["プライマリウェブサイト配下のsubdomain(DNS)"]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataは、2.xバージョンからTreasure Data JavaScript SDK version 3,4を使用したサイトでの新機能や機能の実装を検証することをお勧めします。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"既知の制限事項","__idx":2},"children":["既知の制限事項"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Safari 16.4以降では、server-side cookieは7日間に制限されています。さらに、iOS上の他のbrowserも同じwebkitを使用している場合、同じ制限を受けます。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"dnsでのns-recordのセットアップ","__idx":3},"children":["DNSでのNS Recordのセットアップ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataのserver-side trackingでは、サーバーがプライマリウェブサイトのsubdomain配下にfirst party cookieを作成する必要があります。Treasure Dataのserver-side cookie serviceを指すNS recordをsubdomainに追加する必要があります。NS recordは、subdomainの名前をTreasure Dataのname serverに向けます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["たとえば:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["プライマリウェブサイト: ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://www.example.com/"},"children":["www.example.com"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["subdomain: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ssc"]},".example.com"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"ssc.example.com.\nNS\nns-###.awsdns-##.com.\nns-####.awsdns-##.co.uk.\nns-###.awsdns-##.net.\nns-###.awsdns-##.org.\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["一般的に、ウェブサイト設定の手順に従ってNS recordを追加します。Treasure Dataのカスタマーサクセス担当者が、使用するTreasure Dataサーバーレコードの詳細を提供します。冗長性とDNS lookupの高速化のために複数のレコードを指定することもできます(browserに物理的に最も近いname serverを選択できます)。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"first-party-cookieを収集して保存するためのjs-sdkの設定","__idx":4},"children":["First Party Cookieを収集して保存するためのJS SDKの設定"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ウェブサイトサーバー開発者として、TD JS SDKをインストールし、ウェブサイトを訪問する各ユーザー用にTreasure Dataで生成されたIDをfetchする関数呼び出しを設定します。関数呼び出しは基本的にTreasure Dataのserver-side cookieへのAPI requestです。server-side cookieがウェブサイトに返すIDは、エンドユーザーのbrowserに保存されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["パラメータと関数には以下が含まれます:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["sscDomain: String | (String) => String | null. ウェブサイトのトップレベルdomain。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["sscServer: String | null. Treasure Dataに接続するためにウェブサイトで作成するsubdomain。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["useServerSideCookie: Boolean"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["setSignedMode() 関数"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["trackPageview() 関数"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["set() 関数"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"treasure-data-javascript-sdkの概要とインストール","__idx":5},"children":["Treasure Data JavaScript SDKの概要とインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/quickstart"},"children":["TD JS SDKクイックスタート"]},"を表示できます。また、プライバシー規制と要件に準拠するのに役立つTD JS SDK関数の説明については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/trust/gdpr-support-in-treasure-data"},"children":["Treasure DataでのGDPRサポート"]},"を確認してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TD JS SDKのインストールの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/quickstart"},"children":["Website Trackingの開始"]},"を参照してください。手順の一部である個別にTracking Eventを有効にすることは、first-party cookieのtrackingを有効にするための鍵です。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"server-side-cookieを呼び出すjsコードの埋め込み","__idx":6},"children":["Server Side Cookieを呼び出すJSコードの埋め込み"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["cookieを含むサーバーのJSコードは、パラメータとして指定されたsubdomain上にcookieを設定します。各エンドユーザーvisitor用の一意のidは、ユーザーがcookieをクリアしない限り、2年間永続化されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ユーザーが後でサイトに再訪問すると、同じユーザーとして認識されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure アカウントがwebページからデータをインポートするようにセットアップされていることを確認してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のコード例は、ウェブサイトで設定するパラメータと関数を示しています:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<html>\n  <head>\n    <script type=\"text/javascript\">\n      !function(t,e){if(void 0===e[t]){e[t]=function(){e[t].clients.push(this),this._init=[Array.prototype.slice.call(arguments)]},e[t].clients=[];for(var r=function(t){return function(){return this[\"_\"+t]=this[\"_\"+t]||[],this[\"_\"+t].push(Array.prototype.slice.call(arguments)),this}},s=[\"collectTags\",\"addRecord\",\"blockEvents\",\"fetchServerCookie\",\"fetchGlobalID\",\"fetchUserSegments\",\"fetchPersonalization\",\"resetUUID\",\"ready\",\"setSignedMode\",\"setAnonymousMode\",\"set\",\"trackEvent\",\"trackPageview\",\"trackClicks\",\"unblockEvents\"],c=0;c<s.length;c++){var o=s[c];e[t].prototype[o]=r(o)}var n=document.createElement(\"script\");n.type=\"text/javascript\",n.async=!0,n.src=(\"https:\"===document.location.protocol?\"https:\":\"http:\")+\"//cdn.treasuredata.com/sdk/4.4/td.min.js\";var i=document.getElementsByTagName(\"script\")[0];i.parentNode.insertBefore(n,i)}}(\"Treasure\",this);\n    </script>\n  </head>\n  <body>\n    <script type=\"text/javascript\">\n      var td = new Treasure({\n        database: \"YOUR_DATABASE\",\n        writeKey: \"YOUR_API_KEY\",\n        host: \"us01.records.in.treasuredata.com\",\n        startInSignedMode: true,\n        sscDomain: \"YOUR_SSC_DOMAIN\", // ex) example.com\n        sscServer: \"YOUR_SSC_SERVER\", // ex) ssc.example.com\n        useServerSideCookie: true,\n      });\n\n      td.set(\"$global\", \"td_global_id\", \"td_global_id\");\n      td.fetchServerCookie(successCallback, errorCallback);\n\n      function fireEvents() {\n        td.trackPageview(\"YOUR_TABLE\");\n      }\n\n      function successCallback(result) {\n        // result === Server Side Cookie\n        td.set(\"$global\", { td_ssc_id: result });\n        fireEvents();\n      }\n\n      function errorCallback() {\n        // Track events, even if the server-side cookie does not work\n        fireEvents();\n      }\n    </script>\n  </body>\n</html>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"接続を確立するための既存のjs-sdkの変更","__idx":7},"children":["接続を確立するための既存のJS SDKの変更"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ウェブサイト上の既存のJS SDKコーディングを更新し、前のセクションに示されているように、必要なパラメータと関数を追加します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、Treasure Dataで、first-party cookieデータを受信するdatabase tableにtd_ssc_id用のcolumnが含まれていることを確認します。eventが既存のtableに記録される場合、columnが必要です:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/idsontdblur.4193c29e7243be6ef222ea08cb04efda1220e118a4059cbe95c289ea529ede45.ad50cbca.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"consent-record-locationの指定","__idx":8},"children":["Consent Record locationの指定"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["通常、consentはdocument.cookieなどのclient-side cookieとしてbrowserに保存されます。Treasure Dataは、consentの新しいlocationオプションを提供します。locationはユーザーのlocal storageにあります。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["JS SDKで",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["storeConsentByLocalStorage: true."]},"を指定します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["エンドユーザーがconsentを受け入れると、consentはエンドユーザーのlocal storageに保存されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/consentrecord.78f1d717c3034c612f4b731573833d1e14009b6f3ab150c8dc8f3bceb354969a.ad50cbca.png","alt":""},"children":[]}]}]},"headings":[{"value":"WebサイトでのServer-Side First Party Cookieのtracking","id":"webサイトでのserver-side-first-party-cookieのtracking","depth":1},{"value":"前提条件","id":"前提条件","depth":2},{"value":"既知の制限事項","id":"既知の制限事項","depth":2},{"value":"DNSでのNS Recordのセットアップ","id":"dnsでのns-recordのセットアップ","depth":2},{"value":"First Party Cookieを収集して保存するためのJS SDKの設定","id":"first-party-cookieを収集して保存するためのjs-sdkの設定","depth":2},{"value":"Treasure Data JavaScript SDKの概要とインストール","id":"treasure-data-javascript-sdkの概要とインストール","depth":2},{"value":"Server Side Cookieを呼び出すJSコードの埋め込み","id":"server-side-cookieを呼び出すjsコードの埋め込み","depth":2},{"value":"接続を確立するための既存のJS SDKの変更","id":"接続を確立するための既存のjs-sdkの変更","depth":2},{"value":"Consent Record locationの指定","id":"consent-record-locationの指定","depth":2}],"frontmatter":{"seo":{"title":"WebサイトでのServer-Side First Party Cookieのtracking"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/products/customer-data-platform/integration-hub/streaming/td-javascript-sdk/tracking-server-side-first-party-cookies-on-your-website","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}