{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"イベントトラッキング — In-Browser Messaging","description":"GA4互換の命名規則を使用してIn-Browser Messagingのビジネスイベントを定義・実装する方法を説明します。ページビュー、商品操作、カートイベントなどを網羅します。","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":"イベントトラッキング","__idx":0},"children":["イベントトラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このガイドでは、Webサイトから Treasure AI にビジネスイベントを定義・送信する方法を説明します。適切に設計されたイベントはIn-Browser Messageのターゲティングの基盤となり、キャンペーンのトリガー条件とパーソナライズ属性の利用可能範囲を決定します。"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"責務の分担"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["開発者が定義するもの"]},": ビジネスイベント（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view_item"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["purchase"]},"など）と認証済みユーザーID。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SDKが自動で処理するもの"]},": ページビュー、セッション計測、デバイス/ブラウザプロパティ、メッセージのインプレッションとクリック計測（現在および将来）。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["将来のSDKバージョンではページビューとSPAルート変更も自動計測される予定です。そのため、このページの手動実装パターンは将来的にはオプションになります。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"イベントアーキテクチャ","__idx":1},"children":["イベントアーキテクチャ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ページビュー、ビジネスイベント、将来SDKが自動計測するイベントを含む",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["すべてのイベントを1つのテーブル"]},"に集約します。クエリでは ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["event_name"]}," でイベント種別を区別します。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"発生したこと"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["発生したこと"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"テーブル"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["テーブル"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"40%","data-label":"用途"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["用途"]}," "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ページビュー、セッション開始/終了"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["events"]},"（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["event_name: 'page_view'"]},"）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["RT Entry Criteria、オーディエンスセグメンテーション"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["商品閲覧、カート、購入"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["events"]},"（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["event_name: 'view_item'"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["'add_to_cart'"]}," など）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["RT属性、トリガー条件"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["メッセージ表示 / クリック / 閉じる"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["events"]},"（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["event_name: 'td_msg_shown'"]}," など）— 将来、自動"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["キャンペーンレポート、フリークエンシーキャップ"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ページビュー数のカウント"]},": ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SELECT count(*) FROM events WHERE event_name = 'page_view'"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ga4互換のイベント命名","__idx":2},"children":["GA4互換のイベント命名"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ビジネスイベントには",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["GA4の標準イベント名"]},"の採用を推奨します。GA4をすでに使用しているチームの実装コストを最小化し、GTMのdataLayerを再利用でき、RT 2.0ターゲティングのための一貫したスキーマを提供します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"標準eコマースイベント","__idx":3},"children":["標準Eコマースイベント"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"25%","data-label":"イベント名"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["イベント名"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"35%","data-label":"発火タイミング"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["発火タイミング"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"40%","data-label":"主要プロパティ"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["主要プロパティ"]}," "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view_item"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ユーザーが商品詳細ページを閲覧"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_name"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["price"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_category"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_brand"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["add_to_cart"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ユーザーが商品をカートに追加"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_name"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["price"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["quantity"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view_cart"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ユーザーがカートを開く"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart_total"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_count"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["items"]},"（JSON文字列）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["purchase"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["注文確認ページ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transaction_id"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["revenue"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_count"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["items"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["add_to_wishlist"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ユーザーが商品を保存"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["price"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["login"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ユーザーがログイン"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["method"]},"（例: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"email\""]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"google\""]},"）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sign_up"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ユーザーが登録"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["method"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"プロパティ命名規則","__idx":4},"children":["プロパティ命名規則"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"カテゴリー"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["カテゴリー"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"プロパティ名"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["プロパティ名"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"15%","data-label":"型"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["型"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"25%","data-label":"備考"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["備考"]}," "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["商品ID"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["GA4互換"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["商品名"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_name"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["単価"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["price"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["number"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["注文合計金額"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["revenue"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["number"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["数量"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["quantity"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["number"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["カテゴリー（最大5階層）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_category"]}," ～ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_category5"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["GA4互換"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ブランド"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_brand"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["注文ID"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transaction_id"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["GA4互換"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["商品配列"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["items"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string（JSON）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["後述の配列処理を参照"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"イベントの送信","__idx":5},"children":["イベントの送信"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"基本イベント","__idx":6},"children":["基本イベント"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"td.trackEvent('events', {\n  event_name: 'view_item',\n  item_id: 'SKU-001',\n  item_name: 'Essential Crew Tee',\n  price: 29,\n  item_category: 'tops',\n  item_brand: 'BASIQ',\n})\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"カートイベント","__idx":7},"children":["カートイベント"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// カートに追加\ntd.trackEvent('events', {\n  event_name: 'add_to_cart',\n  item_id: 'SKU-001',\n  item_name: 'Essential Crew Tee',\n  price: 29,\n  quantity: 1,\n  item_category: 'tops',\n})\n\n// カート表示（集計）\ntd.trackEvent('events', {\n  event_name: 'view_cart',\n  cart_total: 87,\n  item_count: 3,\n  items: JSON.stringify([\n    { item_id: 'SKU-001', price: 29, quantity: 1 },\n    { item_id: 'SKU-014', price: 58, quantity: 2 },\n  ]),\n})\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"購入イベント","__idx":8},"children":["購入イベント"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"td.trackEvent('events', {\n  event_name: 'purchase',\n  transaction_id: 'ORDER-10432',\n  revenue: 87,\n  item_count: 3,\n  // 主要商品のフラットフィールド — RTトリガーや属性で使いやすい\n  item_id: 'SKU-001',\n  item_category: 'tops',\n  // 完全な商品配列をJSON文字列として（網羅性のため）\n  items: JSON.stringify([\n    { item_id: 'SKU-001', item_name: 'Essential Crew Tee', price: 29, quantity: 1 },\n    { item_id: 'SKU-014', item_name: 'Wide-leg Pants', price: 58, quantity: 2 },\n  ]),\n})\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"配列データの扱いitems","__idx":9},"children":["配列データの扱い（items）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["複数商品を含むイベント（カート、購入）では、商品リストの送信方法を検討する必要があります。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"アプローチ"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["アプローチ"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"35%","data-label":"メリット"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["メリット"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"35%","data-label":"デメリット"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["デメリット"]}," "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JSON-stringify（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["items: \"[{...}]\""]},"）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["実装が簡単。GTMフレンドリー"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["TDクエリが複雑になる。RT属性では直接使用不可"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["フラット化（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id_0"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_id_1"]},"…）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["クエリしやすい"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["カートサイズに応じてフィールド数が急増"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["推奨: 主要フラット + JSON全リスト"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["トリガーと網羅性の両立"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["実装がやや複雑"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["推奨パターンを使用してください"]},": トリガー条件に最も役立つプロパティ（例: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_category"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["price"]},"）はフラットフィールドとして送信し、完全なリストはレポート用にJSON文字列として追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"td.trackEvent('events', {\n  event_name: 'purchase',\n  transaction_id: 'ORDER-001',\n  revenue: 8760,\n  item_count: 2,\n  // フラット: 主要商品フィールド（RT属性条件で使いやすい）\n  item_id: 'SKU-123',\n  item_category: 'electronics',\n  price: 4380,\n  // JSON文字列としての全リスト（レポート向け）\n  items: JSON.stringify([\n    { item_id: 'SKU-123', item_name: 'Headphones', price: 4380, quantity: 1 },\n    { item_id: 'SKU-456', item_name: 'Case', price: 4380, quantity: 1 },\n  ]),\n})\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sdkロード前のイベント送信","__idx":10},"children":["SDKロード前のイベント送信"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SDKスクリプトが非同期でロードされるページでは、SDKの準備が整う前に送信されたイベントが失われる可能性があります。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["コマンドキューパターン"]},"を使用すると、いつでも安全にイベントを送信でき、SDKの準備が整い次第再生されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// いつでも安全に呼び出せる — SDKが未ロードの場合はキューに追加される\n;(window.__tdEventQueue = window.__tdEventQueue || []).push([\n  'trackEvent', 'events', { event_name: 'view_item', item_id: 'SKU-001', price: 29 }\n])\n\n// SDK初期化コード（sdk-loader.jsなど）内で:\n;(function drainQueue() {\n  var queue = window.__tdEventQueue || []\n  window.__tdEventQueue = { push: function(entry) {\n    if (!entry || !entry.length) return\n    var method = entry[0]\n    if (window.td && typeof window.td[method] === 'function') {\n      window.td[method].apply(window.td, entry.slice(1))\n    }\n  }}\n  queue.forEach(window.__tdEventQueue.push)\n})()\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"gtm連携","__idx":11},"children":["GTM連携"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ga4のdatalayerを活用する","__idx":12},"children":["GA4のdataLayerを活用する"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["GTM経由でGA4イベントをすでに送信しているサイトでは、最小限の追加コードでdataLayerを傍受してTDにイベントを転送できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// GTM Custom HTMLタグ — All Pagesで発火\n<script>\n;(function () {\n  var _push = window.dataLayer.push.bind(window.dataLayer)\n  window.dataLayer.push = function (event) {\n    _push(event)\n    // GA4形式のイベントをTDに転送\n    if (event && event.event && window.td) {\n      var GA4_EVENTS = [\n        'view_item', 'add_to_cart', 'view_cart',\n        'purchase', 'add_to_wishlist', 'login', 'sign_up'\n      ]\n      if (GA4_EVENTS.indexOf(event.event) !== -1) {\n        var props = Object.assign({}, event)\n        props.event_name = props.event   // event_nameフィールドとして保持\n        delete props.event\n        delete props.gtm  // GTM内部プロパティを削除\n        window.td.trackEvent('events', props)\n      }\n    }\n  }\n})()\n</script>\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"GTMのグローバル変数"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TD Web SDKは ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["window.td"]},"（または ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["window.Treasure"]},"）をグローバルとして公開しています。GTMのCustom HTMLタグから追加設定なしで ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["window.td.trackEvent(...)"]}," を呼び出せます。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"イベントごとに個別のgtmタグを作成する","__idx":13},"children":["イベントごとに個別のGTMタグを作成する"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["あるいは、対応するGA4イベントまたはカスタムGTMトリガーで発火する",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Custom HTML"]},"タグをイベントタイプごとに作成することもできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<!-- GTMタグ: GA4の \"view_item\" イベントで発火 -->\n<script>\n  if (window.td && {{ecommerce.items}}) {\n    var item = {{ecommerce.items}}[0] || {}\n    window.td.trackEvent('events', {\n      event_name: 'view_item',\n      item_id: item.item_id,\n      item_name: item.item_name,\n      price: item.price,\n      item_category: item.item_category,\n    })\n  }\n</script>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"rt-20でのイベント活用","__idx":14},"children":["RT 2.0でのイベント活用"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["イベントがTDデータベースに流れ始めると、RT 2.0の以下の機能で利用できるようになります。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"機能"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["機能"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"70%","data-label":"イベントの活用方法"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["イベントの活用方法"]}," "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["RT属性"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["イベント履歴からユーザーごとの属性を計算します（例: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["most_recent_product"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["total_spend"]},"）。Entry Criteriaとオーディエンスセグメンテーションのインプットになります。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Entry Criteria"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["特定のイベント条件が満たされたときにパーソナライズセクションをトリガーします（例: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["item_category == \"electronics\""]},"）。現在はイベント名マッチング（L1）をサポート。プロパティベースのフィルタリング（L2）は計画中です。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["オーディエンスセグメント"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["イベント履歴からバッチセグメントを構築します（例: 「過去30日以内に購入したユーザー」）。キャンペーンターゲティングに使用します。"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"将来sdkが自動計測する予定のイベント","__idx":15},"children":["将来SDKが自動計測する予定のイベント"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のイベントは現在手動実装が必要です。将来のSDKバージョンでは自動的に計測されます。テーブルとフィールド名はSDKイベント要件仕様に定義されています。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"width":"30%","data-label":"イベント"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["イベント"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"20%","data-label":"現在"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["現在"]}," "]},{"$$mdtype":"Tag","name":"th","attributes":{"width":"50%","data-label":"将来（SDK自動）"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["将来（SDK自動）"]}," "]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ページビュー"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["すべてのルート変更で手動 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["trackEvent('events', { event_name: 'page_view' })"]}," 呼び出しが必要"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ページロードおよびSPAルート変更時に自動"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["セッション開始 / 終了"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["利用不可"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["自動（30分タイムアウト。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_session_id"]}," がすべてのイベントに付与される）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["初回訪問"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["利用不可"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["最初のページロード時に自動（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_first_visit"]}," イベント）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["メッセージインプレッション"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["利用不可"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SDKがポップアップまたはインラインメッセージをレンダリングしたときに自動（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_msg_shown"]},"）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["メッセージクリック"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["利用不可"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["CTAの操作時に自動（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_msg_clicked"]},"）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["メッセージ閉じる"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["利用不可"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["閉じるボタン操作時に自動（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_msg_dismissed"]},"）"]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"将来を見据えた実装"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このガイドで説明するGA4互換のイベント名とフラットフィールドパターンを採用すると、将来RT 2.0のトリガー条件機能（L2プロパティマッチング）が追加されてもスキーマ変更なく対応できます。"]}]}]},"headings":[{"value":"イベントトラッキング","id":"イベントトラッキング","depth":1},{"value":"イベントアーキテクチャ","id":"イベントアーキテクチャ","depth":2},{"value":"GA4互換のイベント命名","id":"ga4互換のイベント命名","depth":2},{"value":"標準Eコマースイベント","id":"標準eコマースイベント","depth":3},{"value":"プロパティ命名規則","id":"プロパティ命名規則","depth":3},{"value":"イベントの送信","id":"イベントの送信","depth":2},{"value":"基本イベント","id":"基本イベント","depth":3},{"value":"カートイベント","id":"カートイベント","depth":3},{"value":"購入イベント","id":"購入イベント","depth":3},{"value":"配列データの扱い（items）","id":"配列データの扱いitems","depth":3},{"value":"SDKロード前のイベント送信","id":"sdkロード前のイベント送信","depth":2},{"value":"GTM連携","id":"gtm連携","depth":2},{"value":"GA4のdataLayerを活用する","id":"ga4のdatalayerを活用する","depth":3},{"value":"イベントごとに個別のGTMタグを作成する","id":"イベントごとに個別のgtmタグを作成する","depth":3},{"value":"RT 2.0でのイベント活用","id":"rt-20でのイベント活用","depth":2},{"value":"将来SDKが自動計測する予定のイベント","id":"将来sdkが自動計測する予定のイベント","depth":2}],"frontmatter":{"seo":{"title":"イベントトラッキング — In-Browser Messaging","description":"GA4互換の命名規則を使用してIn-Browser Messagingのビジネスイベントを定義・実装する方法を説明します。ページビュー、商品操作、カートイベントなどを網羅します。"}},"lastModified":"2026-06-18T03:34:22.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/products/marketing-cloud/engage-studio/experiences/event-tracking","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}