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

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

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

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

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

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

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

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

  1. เปิด Google Tag Manager

  2. เปิดเมนูแท็กในพื้นที่ทํางาน

  3. สร้างแท็กใหม่ คลิกช่องการกำหนดค่าแท็ก แล้วเลือกแท็ก Google Analytics: เหตุการณ์ GA4

  4. สําหรับชื่อเหตุการณ์ ให้ใช้ตัวแปรในตัว {{Event}} ซึ่งจะใช้ชื่อเหตุการณ์อีคอมเมิร์ซของ Google Analytics ที่ส่งโดยใช้ gtag.js API

  5. ในส่วนการตั้งค่าเพิ่มเติม > อีคอมเมิร์ซ ให้เลือกส่งข้อมูลอีคอมเมิร์ซ

  6. สำหรับแหล่งข้อมูล ให้เลือกชั้นข้อมูล UI ของ Tag Manager แสดงการกำหนดค่าแท็กอีคอมเมิร์ซ

  7. ตั้งค่าทริกเกอร์สําหรับเหตุการณ์ GA4 เช่น เมื่อผู้ใช้คลิกปุ่ม ชําระเงิน ดูประเภททริกเกอร์ทั้งหมดที่ใช้ได้

  8. ตั้งชื่อและบันทึกแท็ก

คำแนะนำ

  • เปิดใช้โหมดแก้ไขข้อบกพร่องเพื่อให้คุณเห็นเหตุการณ์แบบเรียลไทม์และแก้ปัญหา ได้
  • โปรดตรวจสอบขีดจํากัดของมิติข้อมูลและเมตริกที่กําหนดเองเมื่อส่งพารามิเตอร์ที่กําหนดเองพร้อมกับเหตุการณ์อีคอมเมิร์ซ
  • ตั้งค่า currency เมื่อส่งข้อมูล value (รายได้) เพื่อให้แน่ใจว่าระบบจะคํานวณเมตริกรายได้อย่างถูกต้อง
  • ตั้งค่าพารามิเตอร์อีคอมเมิร์ซแต่ละรายการที่คุณมีข้อมูล ไม่ว่าพารามิเตอร์จะเป็นแบบไม่บังคับหรือไม่ก็ตาม
  • ใช้เว็บไซต์อีคอมเมิร์ซตัวอย่างเพื่อดูตัวอย่างวิธีติดแท็ก เว็บไซต์
  • โปรดทําตามรูปแบบในเอกสารนี้เพื่อให้ข้อมูลแสดงในรายงานอย่างถูกต้อง หากต้องการตั้งค่าอาร์เรย์สินค้าภายนอกอาร์เรย์อีคอมเมิร์ซ ให้ตั้งค่าพารามิเตอร์ currency ที่ระดับเหตุการณ์เมื่อส่งข้อมูล value (รายได้)

การใช้งาน

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

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

ตัวอย่างต่อไปนี้แสดงวิธีสร้างคอลเล็กชันของ 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พารามิเตอร์อาร์เรย์ที่มีรายการที่แสดง ดูรายละเอียด เกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิง เหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: view_item_list
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • รหัสรายการสินค้าอีคอมเมิร์ซ - ecommerce.item_list_id
    • ชื่อรายการสินค้าอีคอมเมิร์ซ - ecommerce.item_list_name
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • item_list_id - {{Ecommerce Item List ID}}
    • item_list_name - {{Ecommerce 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 ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: select_item
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • รหัสรายการสินค้าอีคอมเมิร์ซ - ecommerce.item_list_id
    • ชื่อรายการสินค้าอีคอมเมิร์ซ - ecommerce.item_list_name
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • item_list_id - {{Ecommerce Item List ID}}
    • item_list_name - {{Ecommerce 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เหตุการณ์ ทุกครั้งที่ผู้ใช้ดูหน้าจอรายละเอียดสินค้า ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: view_item
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce 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อาร์เรย์ ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: add_to_cart
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce 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 ดูรายละเอียด เกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิง เหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: add_to_wishlist
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce 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 พร้อมกับสินค้าทั้งหมด ในรถเข็น ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: view_cart
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce 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 เหตุการณ์ ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: remove_from_cart
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce 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 ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: begin_checkout
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce Currency}}
    • coupon - {{Ecommerce 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 เพื่อระบุตัวเลือกการนำส่งของผู้ใช้ เช่น "ทางบก" "ทางอากาศ" หรือ "วันถัดไป" ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: add_shipping_info
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
    • ระดับการจัดส่งอีคอมเมิร์ซ - ecommerce.shipping_tier
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce Currency}}
    • coupon - {{Ecommerce Coupon}}
    • shipping_tier - {{Ecommerce 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 กับเหตุการณ์นี้สำหรับวิธีการชำระเงินที่เลือก ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: add_payment_info
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
    • มูลค่าอีคอมเมิร์ซ - ecommerce.value
    • สกุลเงินอีคอมเมิร์ซ - ecommerce.currency
    • คูปองอีคอมเมิร์ซ - ecommerce.coupon
    • ประเภทการชำระเงินอีคอมเมิร์ซ - ecommerce.payment_type
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • items - {{Ecommerce Items}}
    • value - {{Ecommerce Value}}
    • currency - {{Ecommerce Currency}}
    • coupon - {{Ecommerce Coupon}}
    • payment_type - {{Ecommerce 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 รายการที่กําหนด ด้วยช่องที่เกี่ยวข้อง ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

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

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

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อกิจกรรม: 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",
    customer_type: "new",
    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

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

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

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

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

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

  • ประเภททริกเกอร์: เหตุการณ์ที่กำหนดเอง
  • ชื่อกิจกรรม: 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 เพื่อระบุ สินค้าที่ได้รับการโปรโมต ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ชื่อกิจกรรม: view_promotion
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • ชื่อครีเอทีฟโฆษณาอีคอมเมิร์ซ - ecommerce.creative_name
    • ตําแหน่งครีเอทีฟโฆษณาอีคอมเมิร์ซ - ecommerce.creative_slot
    • รหัสโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_id
    • ชื่อโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_name
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • creative_name - {{Ecommerce Creative Name}}
    • creative_slot - {{Ecommerce Creative Slot}}
    • promotion_id - {{Ecommerce Promotion ID}}
    • promotion_name - {{Ecommerce Promotion Name}}
    • items - {{Ecommerce 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 พร้อมกับ รายการนั้นเป็นพารามิเตอร์รายการ ดูรายละเอียดเกี่ยวกับพารามิเตอร์ที่จะส่งได้ที่ข้อมูลอ้างอิงเหตุการณ์

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

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

  • ประเภทแท็ก: Google Analytics: เหตุการณ์ GA4
  • ตัวแปรชั้นข้อมูล (ชื่อ - ชื่อตัวแปรชั้นข้อมูล):
    • ชื่อครีเอทีฟโฆษณาอีคอมเมิร์ซ - ecommerce.creative_name
    • ตําแหน่งครีเอทีฟโฆษณาอีคอมเมิร์ซ - ecommerce.creative_slot
    • รหัสโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_id
    • ชื่อโปรโมชันอีคอมเมิร์ซ - ecommerce.promotion_name
    • สินค้าอีคอมเมิร์ซ - ecommerce.items
  • พารามิเตอร์เหตุการณ์ (ชื่อพารามิเตอร์ - ค่า):
    • creative_name - {{Ecommerce Creative Name}}
    • creative_slot - {{Ecommerce Creative Slot}}
    • promotion_id - {{Ecommerce Promotion ID}}
    • promotion_name - {{Ecommerce Promotion Name}}
    • items - {{Ecommerce 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
  • ชื่อเหตุการณ์: ใดก็ได้
  • อ่านข้อมูลจากตัวแปร: {{gaEcommerceData}}
  • ทริกเกอร์: เหตุการณ์เท่ากับ gtm.dom

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

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