通知

このヘルプセンターでは、Merchant Center Next と従来の Merchant Center の両方に関するコンテンツをご覧いただけます。参照している記事がご利用の Merchant Center バージョンのものであるかどうかは、各記事の上部にあるロゴで確認してください。

Google タグの購入イベントを設定する

従来の Merchant Center の記事ヘッダーのカスタム アイコン。

ウェブサイトで購入イベントを設定して Merchant Center にリンクすると、すべてのコンバージョンをトラッキングできます。この記事では、ウェブサイトで購入イベントを設定する方法について説明します。

仕組み

コンバージョン データを収集するには、ウェブサイトで購入イベントをトラッキングする必要があります。イベントをトラッキングするには、ウェブサイトでイベントを定義します。

以下では、ウェブサイトから購入イベントを送信する方法の例を 2 つ紹介します。

例 1: ページが開いたときに購入イベントを送信する

ウェブサイトの、購入が発生するページに購入イベントを配置する方法です。たとえば、購入時に表示される確認ページなどに、このイベントを追加します。このチュートリアルでは、ユーザーが [購入] ボタンをクリックするページにイベントを追加する方法を説明します。

イベントを、<body> タグの末尾の <script> タグ内に配置してください。イベントを <script> タグ内に直接配置することで、ページ読み込み時にイベントがトリガーされます。

サンプルコード

<!--
  Note: In the following code sample, make sure to
  replace "TAG_ID" with your tag ID.
  Learn more: https://support.google.com/tagmanager/answer/12326985
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Google tag (gtag.js) -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());


        gtag('config', 'TAG_ID');
    </script>
</head>
<body>
    <div>This is where the purchase form would go</div>
    <button>Submit</button>
    <script>
    gtag("event", "purchase", {
        transaction_id: "T_12345_1",
        affiliation: "Google Merchandise Store",
        value: 25.42,
        tax: 4.90,
        shipping: 5.99,
        currency: "USD",
        coupon: "SUMMER_SALE",
        items: [
        // If someone purchases more than one item,
        // you can add those items to the items array
         {
          item_id: "SKU_12345",
          item_name: "Stan and Friends Tee",
          affiliation: "Google Merchandise Store",
          coupon: "SUMMER_FUN",
          discount: 2.22,
          index: 0,
          item_brand: "Google",
          item_category: "Apparel",
          item_category2: "Adult",
          item_category3: "Shirts",
          item_category4: "Crew",
          item_category5: "Short sleeve",
          item_list_id: "related_products",
          item_list_name: "Related Products",
          item_variant: "green",
          location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
          price: 9.99,
          quantity: 1
        }]
    });
    </script>
</body>
</html>

例 2: ボタンがクリックされたときに購入イベントを送信する

[購入] ボタンのクリック時に購入イベントがトリガーされるように設定するには、いくつかの方法があります。1 つは、[購入] ボタンに ID を追加し、イベントコードをイベント リスナーに配置する方法です。以下の例では、ID が追加された購入ボタンがクリックされた場合にのみイベントが送信されます。

サンプルコード

<!--
  Note: In the following code sample, make sure to
  replace "TAG_ID" with your tag ID.
  Learn more: https://support.google.com/tagmanager/answer/12326985
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Google tag (gtag.js) -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());


        gtag('config', 'TAG_ID');
    </script>
</head>
<body>
    <div>This is where the purchase form would go</div>
    <button id="purchase">Purchase</button>
    <script>
    document.getElementById("purchase").addEventListener("click", function () {
        gtag("event", "purchase", {
                // This purchase event uses a different transaction ID
                // from the previous purchase event so Analytics
                // doesn't deduplicate the events.
                // Learn more: https://support.google.com/analytics/answer/12313109
                transaction_id: "T_12345_2",
                affiliation: "Google Merchandise Store",
                value: 25.42,
                tax: 4.90,
                shipping: 5.99,
                currency: "USD",
                coupon: "SUMMER_SALE",
                items: [
                {
                  item_id: "SKU_12345",
                  item_name: "Stan and Friends Tee",
                  affiliation: "Google Merchandise Store",
                  coupon: "SUMMER_FUN",
                  discount: 2.22,
                  index: 0,
                  item_brand: "Google",
                  item_category: "Apparel",
                  item_category2: "Adult",
                  item_category3: "Shirts",
                  item_category4: "Crew",
                  item_category5: "Short sleeve",
                  item_list_id: "related_products",
                  item_list_name: "Related Products",
                  item_variant: "green",
                  location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
                  price: 9.99,
                  quantity: 1
                }]
          });
      });
    </script>
</body>
</html>

購入イベントを Merchant Center にリンクする

コンバージョンの発生元を使用すると、購入イベントを Merchant Center にリンクできます。

詳しくは、Merchant Center でコンバージョンの発生元を追加する方法をご覧ください。

関連リンク

この情報は役に立ちましたか?

改善できる点がありましたらお聞かせください。
検索
検索をクリア
検索を終了
メインメニュー
12235198640275752133
true
ヘルプセンターを検索
true
true
true
true
true
71525
false
false