คุณสามารถตั้งค่าเหตุการณ์อีคอมเมิร์ซเพื่อรวบรวมข้อมูลเกี่ยวกับพฤติกรรมการช็อปปิ้งของผู้ใช้ กิจกรรมนี้จะช่วยให้คุณวัดผลิตภัณฑ์ที่ได้รับความนิยมสูงสุดและดูอิทธิพลของโปรโมชันและตำแหน่งผลิตภัณฑ์ที่มีต่อรายได้
บทความนี้อธิบายเหตุการณ์อีคอมเมิร์ซแต่ละเหตุการณ์และกรณีที่ควรตั้งค่าเหตุการณ์ ดูตัวอย่างทีละขั้นตอนของวิธีตั้งค่าเหตุการณ์อีคอมเมิร์ซได้ที่ตั้งค่าเหตุการณ์การซื้อ
ก่อนเริ่มต้น
ตรวจสอบว่าคุณได้เพิ่มแท็ก Google ลงในเว็บไซต์แล้ว รวมถึงเข้าถึง Analytics และซอร์สโค้ดของเว็บไซต์ได้
การแนะนำวิดีโอ
- เปิดใช้โหมดแก้ไขข้อบกพร่องเพื่อให้คุณดูเหตุการณ์แบบเรียลไทม์และแก้ปัญหาได้ง่ายขึ้น
- ตรวจสอบขีดจํากัดมิติข้อมูลและเมตริกที่กําหนดเองเมื่อส่งพารามิเตอร์ที่กําหนดเองพร้อมกับเหตุการณ์อีคอมเมิร์ซ
- ตั้งค่า
currency
เมื่อส่งข้อมูล (รายได้)value
เพื่อให้คำนวณเมตริกรายได้ได้อย่างถูกต้อง - ตั้งค่าพารามิเตอร์อีคอมเมิร์ซแต่ละรายการที่คุณมีข้อมูล โดยไม่คํานึงถึงพารามิเตอร์ว่าไม่บังคับ
- ใช้ตัวอย่างเว็บไซต์อีคอมเมิร์ซเพื่อดูตัวอย่างวิธีติดแท็กเว็บไซต์
การใช้งาน
การใช้งานอีคอมเมิร์ซโดยทั่วไปจะวัดการกระทำต่อไปนี้
- เลือกสินค้าจากรายการ
- ดูรายละเอียดสินค้า
- เพิ่ม/นำผลิตภัณฑ์ออกจากรถเข็นช็อปปิ้ง
- เริ่มกระบวนการชําระเงิน
- ทำการซื้อหรือขอเงินคืน
- ใช้โปรโมชัน
หัวใจสำคัญของการกระทำเหล่านี้คือผลิตภัณฑ์และบริการที่คุณขาย คุณแสดงผลิตภัณฑ์และบริการเป็นอาร์เรย์ของสินค้าที่เพิ่มลงในเหตุการณ์อีคอมเมิร์ซได้ คุณยังใส่พารามิเตอร์ที่กำหนดเองได้สูงสุด 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
}
],
});