วัดอีคอมเมิร์ซ

คุณสามารถตั้งค่าเหตุการณ์อีคอมเมิร์ซเพื่อรวบรวมข้อมูลเกี่ยวกับพฤติกรรมการช็อปปิ้งของผู้ใช้ กิจกรรมช่วยให้คุณวัดปริมาณผลิตภัณฑ์ที่ได้รับความนิยมสูงสุดและดูผลกระทบของโปรโมชันและโฆษณาแฝงที่มีต่อรายได้

เอกสารนี้อธิบายเหตุการณ์อีคอมเมิร์ซแต่ละรายการและเวลาที่ควรตั้งค่าเหตุการณ์ ดูตัวอย่างวิธีตั้งค่าเหตุการณ์อีคอมเมิร์ซแบบทีละขั้นตอนได้ในหัวข้อตั้งค่าเหตุการณ์การซื้อ

ตรวจสอบว่าได้เพิ่มแท็ก Google ลงในเว็บไซต์แล้ว รวมทั้งเข้าถึง Analytics และซอร์สโค้ดของเว็บไซต์ได้

การใช้งาน

การใช้การติดตั้งใช้งานอีคอมเมิร์ซโดยปกติจะวัดการกระทำต่อไปนี้

หัวใจสำคัญของการกระทำเหล่านี้คือผลิตภัณฑ์และบริการที่คุณขาย คุณสามารถแสดงผลิตภัณฑ์และบริการเป็นอาร์เรย์ของสินค้าที่เพิ่มลงในเหตุการณ์อีคอมเมิร์ซได้ คุณใส่พารามิเตอร์ที่กําหนดเองได้สูงสุด 27 รายการในอาร์เรย์ items นอกเหนือจากพารามิเตอร์ที่กําหนดไว้

ตัวอย่างต่อไปนี้แสดงวิธีสร้างคอลเล็กชันของ items ที่มีการกล่าวถึงในคู่มือนี้ อาร์เรย์ items มีองค์ประกอบได้สูงสุด 200 รายการ

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: 10.01,
      quantity: 3
    },
    {
      item_id: "SKU_12346",
      item_name: "Google Grey Women's Tee",
      affiliation: "Google Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 3.33,
      index: 1,
      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: "gray",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 21.01,
      quantity: 2
    }
]

เลือกสินค้าจากรายการ

เมื่อผู้ใช้เห็นรายการผลลัพธ์ ให้ส่งเหตุการณ์ view_item_list พร้อมพารามิเตอร์อาร์เรย์ items ที่มีรายการที่แสดง ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "view_item_list", {
  item_list_id: "related_products",
  item_list_name: "Related products",
  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: 10.01,
      quantity: 3
    }
  ]
});

เมื่อผู้ใช้เลือกรายการจากรายการแล้ว ให้ส่งเหตุการณ์ select_item พร้อมรายการที่เลือกในพารามิเตอร์อาร์เรย์ items ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "select_item", {
  item_list_id: "related_products",
  item_list_name: "Related products",
  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: 10.01,
      quantity: 3
    }
  ]
});

ดูรายละเอียดรายการ

หากต้องการวัดจํานวนครั้งที่มีการดูรายละเอียดสินค้า ให้ส่งเหตุการณ์ view_item ทุกครั้งที่ผู้ใช้ดูหน้าจอรายละเอียดของสินค้า ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "view_item", {
  currency: "USD",
  value: 30.03,
  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: 10.01,
      quantity: 3
    }
  ]
});

เพิ่มหรือนำสินค้าออกจากรถเข็นช็อปปิ้ง

วัดสินค้าที่เพิ่มลงในรถเข็นช็อปปิ้งโดยการส่งเหตุการณ์ add_to_cart พร้อมสินค้าที่สําคัญในอาร์เรย์ items ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "add_to_cart", {
  currency: "USD",
  value: 30.03,
  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: 10.01,
      quantity: 3
    }
  ]
});

นอกจากนี้ คุณยังวัดได้เมื่อมีการเพิ่มสินค้าลงในรายการที่อยากได้โดยการส่งเหตุการณ์ add_to_wishlist ที่มีรายการที่เกี่ยวข้องในอาร์เรย์ items ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "add_to_wishlist", {
  currency: "USD",
  value: 30.03,
  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: 10.01,
      quantity: 3
    }
  ],
});

เมื่อผู้ใช้ดูรถเข็นในภายหลัง ให้ส่งเหตุการณ์ view_cart พร้อมสินค้าทั้งหมดในรถเข็น ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "view_cart", {
  currency: "USD",
  value: 30.03,
  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: 10.01,
      quantity: 3
    }
  ]
});

หากต้องการวัดเมื่อผู้ใช้นำสินค้าออกจากรถเข็น ให้ส่งเหตุการณ์ remove_from_cart ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "remove_from_cart", {
  currency: "USD",
  value: 30.03,
  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: 10.01,
      quantity: 3
    }
  ]
});

เริ่มกระบวนการชำระเงิน

วัดขั้นตอนแรกในกระบวนการชำระเงินโดยการส่งเหตุการณ์ begin_checkout ที่มีสินค้าอย่างน้อย 1 รายการซึ่งกำหนดด้วยช่องที่เกี่ยวข้อง นอกจากนี้ คุณยังเพิ่มคูปองลงในคำสั่งซื้อทั้งหมดในขั้นตอนนี้ได้ด้วยการเพิ่มลงในเหตุการณ์ หรือนำไปใช้กับสินค้าหนึ่งๆ โดยการเพิ่มลงในองค์ประกอบที่เฉพาะเจาะจงในอาร์เรย์ items ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "begin_checkout", {
  currency: "USD",
  value: 30.03,
  coupon: "SUMMER_FUN",
  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: 10.01,
      quantity: 3
    }
  ]
});

เมื่อผู้ใช้ไปยังขั้นตอนถัดไปในกระบวนการชําระเงินและเพิ่มข้อมูลการจัดส่ง ให้ส่งเหตุการณ์ add_shipping_info ใช้พารามิเตอร์ shipping_tier เพื่อระบุตัวเลือกการนำส่งของผู้ใช้ เช่น "ทางบก" "ทางอากาศ" หรือ "วันถัดไป" ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่การอ้างอิงเหตุการณ์

gtag("event", "add_shipping_info", {
  currency: "USD",
  value: 30.03,
  coupon: "SUMMER_FUN",
  shipping_tier: "Ground",
  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: 10.01,
      quantity: 3
    }
  ]
});

ส่งเหตุการณ์ add_payment_info เมื่อผู้ใช้ส่งข้อมูลการชำระเงิน หากมี ให้ใส่ payment_type กับเหตุการณ์นี้สำหรับวิธีการชำระเงินที่เลือก ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "add_payment_info", {
  currency: "USD",
  value: 30.03,
  coupon: "SUMMER_FUN",
  payment_type: "Credit Card",
  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: 10.01,
      quantity: 3
    }
  ]
});

ทำการซื้อหรือคืนเงิน

วัดการซื้อโดยการส่งเหตุการณ์ purchase ที่มีสินค้าอย่างน้อย 1 รายการซึ่งกําหนดด้วยช่องที่เกี่ยวข้อง ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "purchase", {
    transaction_id: "T_12345",
    // Sum of (price * quantity) for all items.
    value: 72.05,
    tax: 3.60,
    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: 10.01,
      quantity: 3
    },
    {
      item_id: "SKU_12346",
      item_name: "Google Grey Women's Tee",
      affiliation: "Google Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 3.33,
      index: 1,
      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: "gray",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 21.01,
      promotion_id: "P_12345",
      promotion_name: "Summer Sale",
      quantity: 2
    }]
});
ซึ่งระบบจะรายงานโดยอัตโนมัติ

วัดการคืนเงินโดยการส่งเหตุการณ์ refund ที่มีtransaction_idที่เกี่ยวข้องซึ่งระบุไว้ และรายการอย่างน้อย 1 รายการที่กําหนดด้วย item_id และ quantity เราขอแนะนําให้คุณระบุข้อมูลสินค้าในเหตุการณ์ refund เพื่อดูเมตริกการคืนเงินระดับสินค้าใน Analytics

ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "refund", {
  currency: "USD",
  transaction_id: "T_12345", // Transaction ID. Required for purchases and refunds.
  value: 30.03,
  coupon: "SUMMER_FUN",
  shipping: 3.33,
  tax: 1.11,
  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: 10.01,
      quantity: 3
    }
  ]
});

ใช้โปรโมชัน

อีคอมเมิร์ซรองรับการวัดการแสดงผลและการคลิกของการโปรโมตภายใน เช่น แบนเนอร์ที่แสดงเพื่อโปรโมตการขาย

โดยปกติแล้ว การแสดงผลโปรโมชันจะวัดด้วยการดูหน้าจอเริ่มต้นโดยการส่งเหตุการณ์ view_promotion ที่มีพารามิเตอร์ items เพื่อระบุรายการที่โปรโมต ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "view_promotion", {
  creative_name: "Summer Banner",
  creative_slot: "featured_app_1",
  promotion_id: "P_12345",
  promotion_name: "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: 10.01,
      quantity: 3
    }
  ]
});

หากต้องการระบุว่าผู้ใช้คลิกโปรโมชัน ให้ส่งเหตุการณ์ select_promotion พร้อมใช้รายการนั้นที่พารามิเตอร์รายการ ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

gtag("event", "select_promotion", {
  creative_name: "Summer Banner",
  creative_slot: "featured_app_1",
  promotion_id: "P_12345",
  promotion_name: "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: 10.01,
      quantity: 3
    }
  ],
});