Google Analytics 4 實現電子商務事件设定

Google Analytics Haran 3年前 (2022-03-27) 3299次瀏覽 0條留言

如果你是用GTM安裝GA4的方式,延伸閱讀:Google Analytics 4 :Google Tag Manager電商设定指南

這一節我們來介紹,如果你不是用Google Tag Manager去安裝Google Analytics 4,而是通過直接安裝gtag.js追蹤程式的方式,看如何實現電子商務的設定。

由於沒有使用Google Tag Manager,所以需要工程師去通過程式直接實現電子商務事件,它直接就能夠將事件發送給GA4,接下來,我們來看不同電商位置需要安裝的程式:

 

普通產品

  • view_item_list :產品展示
  • view_item:查看產品
  • select_item:點擊產品

 

view_item_list :產品展示

gtag('event', 'view_item_list', {
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    index: 5,
    item_list_name: 'Related Products',
    item_list_id: 'related_products',
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  item_list_name: 'Related products',
  item_list_id: 'related_products'
});

 

注意item_list_name 或 item_list_id 的值必須保持穩定。對于給定列表,這些值應始終相同。

view_item:查看產品

gtag('event', 'view_item', {
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  value: 9.99
});

 

 

select_item:點擊產品

gtag('event', 'select_item', {
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    index: 5,
    item_list_name: 'Related Products',
    item_list_id: 'related_products',
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  item_list_name: 'Related products',
  item_list_id: 'related_products'
});

 

 

促銷產品

  • view_promotion:展示促銷產品
  • select_promotion:點擊促銷產品

 

view_promotion:展示促銷產品

gtag('event', 'view_promotion', {
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    promotion_id: 'P_12345',
    promotion_name: 'Summer Sale',
    creative_slot: 'featured_app_1',
    location_id: 'L_12345',
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'Black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  location_id: 'L_12345'
});

 

select_promotion:點擊促銷產品

gtag('event', 'select_promotion', {
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    promotion_id: 'P_12345',
    promotion_name: 'Summer Sale',
    creative_name: 'Summer Banner',
    creative_slot: 'featured_app_1',
    location_id: 'L_12345',
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'Black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  location_id: 'L_12345'
});

 

購物車

  • add_to_cart:將產品添加到購物車
  • remove_from_cart:将產品從購物車中移除

购物车中currency和value是必须字段。

 

add_to_cart:將產品添加到購物車

gtag('event', 'add_to_cart', {
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  value: 7.77
});

 

 

remove_from_cart:將產品從購物車移除

gtag('event', 'remove_from_cart', {
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  value: 7.77
});

 

結算流程

  • begin_checkout:開始結算
  • add_payment_info:添加支付信息
  • add_shipping_info:添加地址信息
  • purchase:購買成功
  • refund:退款

currency和value是必须字段,購買成功和退款中transaction_id是必须字段。

begin_checkout:開始結算

gtag('event', 'begin_checkout', {
  coupon: 'SUMMER_FUN',
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  value: 7.77
});

 

add_payment_info:添加支付信息

gtag('event', 'add_payment_info', {
  coupon: 'SUMMER_FUN',
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  payment_type: 'Credit Card',
  value: 9.99
});

 

add_shipping_info:添加地址信息

gtag('event', 'add_shipping_info', {
  coupon: 'SUMMER_FUN',
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'Black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  shipping_tier: 'Ground',
  value: 7.77
});

 

purchase:購買成功

gtag('event', 'purchase', {
  affiliation: 'Google Store',
  coupon: 'SUMMER_FUN',
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }, {
    item_id: 'SKU_12346',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'gray',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  transaction_id: 'T_12345',
  shipping: 3.33,
  value: 21.09,
  tax: 2.22
})

 

refund:退款

退款分為全額退款和部分退款

全额退款

gtag('event', 'refund', {
  affiliation: 'Google Store',
  coupon: 'SUMMER_FUN',
  currency: 'USD',
  transaction_id: 'T_12345',
  shipping: 3.33,
  value: 12.21,
  tax: 1.11
});

 

部分退款

gtag('event', 'refund', {
  affiliation: 'Google Store',
  coupon: 'SUMMER_FUN',
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'jeggings',
    coupon: 'SUMMER_FUN',
    discount: 2.22,
    affiliation: 'Google Store',
    item_brand: 'Gucci',
    item_category: 'pants',
    item_variant: 'black',
    price: 9.99,
    currency: 'USD',
    quantity: 1
  }],
  transaction_id: 'T_12345',
  shipping: 3.33,
  value: 12.21,
  tax: 1.11
});

 

 


如果您在操作上仍有任何疑問,歡迎留言交流,或加入:Google Analytics 4交流社團發問
Like (1)
發佈我的留言
取消留言
表情 贴图 加粗 删除线 居中 斜体

Hi,*为發佈留言必須填寫。

  • 顯示名稱*
  • 電子郵件地址*
  • 個人網站網址