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

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

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

ก่อนเริ่มต้น

เพิ่มแท็กการกําหนดค่า GA4 ลงในเว็บไซต์

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

วัดเหตุการณ์อีคอมเมิร์ซด้วยแท็กเหตุการณ์ GA4

วิธีส่งเหตุการณ์และพารามิเตอร์อีคอมเมิร์ซไปยังพร็อพเพอร์ตี้ GA4

  1. เปิด Google Tag Manager
  2. เปิดเมนูแท็กในพื้นที่ทํางาน
  3. สร้างแท็กใหม่ คลิกช่องการกําหนดค่าแท็ก แล้วเลือกแท็ก Google Analytics: เหตุการณ์ GA4
  4. สำหรับชื่อเหตุการณ์ ให้ใช้ตัวแปรในตัว {{Event}} ซึ่งจะใช้ชื่อเหตุการณ์อีคอมเมิร์ซของ GA4 ที่ส่งโดยใช้ API ของ gtag.js
  5. ในส่วนการตั้งค่าเพิ่มเติม > อีคอมเมิร์ซ ให้เลือกส่งข้อมูลอีคอมเมิร์ซ
  6. สำหรับแหล่งข้อมูล ให้เลือกชั้นข้อมูล ส่งข้อมูลอีคอมเมิร์ซ
  7. ตั้งค่าทริกเกอร์สําหรับเหตุการณ์ GA4 เช่น เมื่อผู้ใช้คลิกปุ่มชําระเงิน ดูประเภททริกเกอร์ที่ใช้ได้ทั้งหมด
  8. ตั้งชื่อและบันทึกแท็ก

การแนะนำวิดีโอ

การใช้งาน

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

หัวใจสำคัญของการกระทำเหล่านี้คือผลิตภัณฑ์และบริการที่คุณขาย คุณแสดงผลิตภัณฑ์และบริการเป็นอาร์เรย์ของสินค้าที่เพิ่มลงในเหตุการณ์อีคอมเมิร์ซได้ คุณยังใส่พารามิเตอร์ที่กำหนดเองได้สูงสุด 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
    }
]

ย้ายข้อมูลจากการติดตั้งใช้งานอีคอมเมิร์ซของ UA

หากใช้อีคอมเมิร์ซสําหรับ Universal Analytics อยู่แล้ว คุณสามารถทําอย่างใดอย่างหนึ่งต่อไปนี้เพื่อย้ายข้อมูลไปยัง Google Analytics 4

  • ใช้การติดตั้งใช้งานอีคอมเมิร์ซของ UA เพื่อป้อนข้อมูลเหตุการณ์อีคอมเมิร์ซของ GA4
  • แทนที่การติดตั้งใช้งานอีคอมเมิร์ซของ UA ด้วยเหตุการณ์อีคอมเมิร์ซของ GA4

ดูข้อมูลเกี่ยวกับวิธีเปลี่ยนการใช้งานอีคอมเมิร์ซจาก Universal Analytics เป็น Google Analytics 4 ได้ที่คู่มือการย้ายข้อมูลอีคอมเมิร์ซของ GA4 สําหรับ Google Tag Manager

ล้างออบเจ็กต์อีคอมเมิร์ซ

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

dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.

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

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

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: view_item_list
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • รหัสรายการอีคอมเมิร์ซ - ecommerce.item_list_id
    • ชื่อรายการอีคอมเมิร์ซ - ecommerce.item_list_name
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • item_list_id - {{รหัสรายการอีคอมเมิร์ซ}}
    • item_list_name - {{ชื่อรายการอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ view_item_list

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: view_item_list
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_item_list",
  ecommerce: {
    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.03,
      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
    }]
  }
});

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

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: select_item
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • รหัสรายการอีคอมเมิร์ซ - ecommerce.item_list_id
    • ชื่อรายการอีคอมเมิร์ซ - ecommerce.item_list_name
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • item_list_id - {{รหัสรายการอีคอมเมิร์ซ}}
    • item_list_name - {{ชื่อรายการอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ select_item

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: select_item
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "select_item",
  ecommerce: {
    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 ทุกครั้งที่ผู้ใช้ดูหน้าจอรายละเอียดของสินค้า ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: view_item
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ view_item

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: view_item
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_item",
  ecommerce: {
    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 ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: add_to_cart
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ add_to_cart

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: add_to_cart
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_to_cart",
  ecommerce: {
    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 ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: add_to_wishlist
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ add_to_wishlist

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: add_to_wishlist
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_to_wishlist",
  ecommerce: {
    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 ที่มีสินค้าทั้งหมดในรถเข็น ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: view_cart
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ view_cart

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: view_cart
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_cart",
  ecommerce: {
    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 ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ในข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: remove_from_cart
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ remove_from_cart

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: remove_from_cart
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "remove_from_cart",
  ecommerce: {
    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 ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: begin_checkout
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
    • coupon - {{คูปองอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ begin_checkout

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: begin_checkout
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "begin_checkout",
  ecommerce: {
    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 เพื่อระบุตัวเลือกการนำส่งของผู้ใช้ เช่น "ภาคพื้นดิน" "อากาศ" หรือ "วันถัดไป" ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ในข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: add_shipping_info
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
    • ระดับการจัดส่งอีคอมเมิร์ซ - ecommerce.shipping_tier
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
    • coupon - {{คูปองอีคอมเมิร์ซ}}
    • shipping_tier - {{ระดับการจัดส่งอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ add_shipping_info

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: add_shipping_info
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_shipping_info",
  ecommerce: {
    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 พร้อมกับเหตุการณ์นี้สำหรับวิธีการชำระเงินที่เลือก (หากมี) ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ในข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: add_payment_info
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
    • ประเภทการชำระเงินอีคอมเมิร์ซ - ecommerce.payment_type
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
    • coupon - {{คูปองอีคอมเมิร์ซ}}
    • payment_type - {{ประเภทการชำระเงินอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ add_payment_info

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: add_payment_info
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_payment_info",
  ecommerce: {
    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 รายการที่ระบุด้วยช่องที่เกี่ยวข้อง ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: purchase
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • รหัสธุรกรรมอีคอมเมิร์ซ - ecommerce.transaction_id
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • ภาษีอีคอมเมิร์ซ - ecommerce.tax
    • การจัดส่งอีคอมเมิร์ซ - ecommerce.shipping
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • transaction_id - {{รหัสธุรกรรมอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • tax - {{ภาษีอีคอมเมิร์ซ}}
    • shipping - {{การจัดส่งอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
    • coupon - {{คูปองอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับการซื้อ

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: purchase
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
    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

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

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: refund
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • รายการอีคอมเมิร์ซ - ecommerce.items
    • รหัสธุรกรรมอีคอมเมิร์ซ - ecommerce.transaction_id
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • ภาษีอีคอมเมิร์ซ - ecommerce.tax
    • การจัดส่งอีคอมเมิร์ซ - ecommerce.shipping
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{รายการอีคอมเมิร์ซ}}
    • transaction_id - {{รหัสธุรกรรมอีคอมเมิร์ซ}}
    • value - {{มูลค่าอีคอมเมิร์ซ}}
    • tax - {{ภาษีอีคอมเมิร์ซ}}
    • shipping - {{การจัดส่งอีคอมเมิร์ซ}}
    • currency - {{สกุลเงินอีคอมเมิร์ซ}}
    • coupon - {{คูปองอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับการคืนเงิน

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: refund
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "refund",
  ecommerce: {
    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 เพื่อระบุรายการที่โปรโมต ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: view_promotion
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • ชื่อครีเอทีฟโฆษณาอีคอมเมิร์ซ - ecommerce.creative_name
    • ช่องโฆษณาอีคอมเมิร์ซ - ecommerce.creative_slot
    • รหัสโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_id
    • ชื่อโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_name
    • รายการอีคอมเมิร์ซ - ecommerce.items
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • creative_name - {{ชื่อครีเอทีฟโฆษณาอีคอมเมิร์ซ}}
    • creative_slot - {{ช่องครีเอทีฟโฆษณาอีคอมเมิร์ซ}}
    • promotion_id - {{รหัสโปรโมชันอีคอมเมิร์ซ}}
    • promotion_name - {{ชื่อโปรโมชันอีคอมเมิร์ซ}}
    • items - {{รายการอีคอมเมิร์ซ}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ view_promotion

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: view_promotion
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_promotion",
  ecommerce: {
    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 ที่มีสินค้านั้นเป็นพารามิเตอร์สินค้า ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

แสดงการกำหนดค่าแท็ก

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • ชื่อครีเอทีฟโฆษณาอีคอมเมิร์ซ - ecommerce.creative_name
    • ช่องโฆษณาอีคอมเมิร์ซ - ecommerce.creative_slot
    • รหัสโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_id
    • ชื่อโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_name
    • รายการอีคอมเมิร์ซ - ecommerce.items
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • creative_name - {{ชื่อครีเอทีฟโฆษณาอีคอมเมิร์ซ}}
    • creative_slot - {{ช่องครีเอทีฟโฆษณาอีคอมเมิร์ซ}}
    • promotion_id - {{รหัสโปรโมชันอีคอมเมิร์ซ}}
    • promotion_name - {{ชื่อโปรโมชันอีคอมเมิร์ซ}}
    • items - {{รายการอีคอมเมิร์ซ}}
  • ประเภทตัวแปร: ตัวแปรชั้นข้อมูล - "ecommerce.items"
  • ทริกเกอร์: เหตุการณ์เท่ากับ select_promotion

การกำหนดค่าทริกเกอร์:

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อเหตุการณ์: select_promotion
  • ทริกเกอร์นี้เริ่มทำงานในเหตุการณ์ที่กำหนดเองทั้งหมด
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "select_promotion",
  ecommerce: {
    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
    }
    ]
  }
});

ใช้ตัวแปร JavaScript ที่กำหนดเอง

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

// A Custom JavaScript Variable that returns an ecommerceData object
// that follows the data layer syntax.
function getEcommerceData() {
  var ecommerceProductData = [
    {
      item_name: "Stan and Friends Tee",
      item_id: "SKU_12345",  // ID is required.
      // Rest of the product data should follow the data layer syntax.
    },
    // Multiple products may be included.
  ];
  return ecommerceProductData;
}

หากเลือกใช้ตัวแปร JavaScript ที่กำหนดเอง คุณจะใช้ตัวแปรดังกล่าวได้ในลักษณะเดียวกันกับการใช้ชั้นข้อมูล โดยคุณจะระบุค่าจากพารามิเตอร์ 'items' เป็นพารามิเตอร์เหตุการณ์ในการกำหนดค่าแท็กได้

การกำหนดค่าแท็ก:

  • ประเภทแท็ก: เหตุการณ์ GA4
  • ชื่อเหตุการณ์: any
  • อ่านข้อมูลจากตัวแปร: {{gaEcommerceData}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ gtm.dom

การตั้งค่าตัวแปร gaEcommerceData

  • ประเภทตัวแปร: JavaScript ที่กําหนดเอง
  • ฟังก์ชันเนื้อหา: ใช้ตัวอย่างด้านบน