Google Analytics 4 布署电子商务

Google Analytics 4 Haran 2年前 (2022-06-01) 10604次浏览 42个评论
文章目录[隐藏]

如果你是用GTM安裝GA4的方式,可以参考:Google Analytics 4 :Google Tag Manager电商配置指南

布署的过程中可能会遇到一些问题,可以参考:Google Analytics 4 电子商务跟踪常见问题

这一节我们来介绍,如果你不用Google Tag Manager去安装Google Analytics44,而是通过直接安装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
});

 

 


如有疑问,可以在文章底部留言或邮件(haran.huang@ichdata.com) 我~
喜欢 (15)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址