我在订单确认页面上使用了Universal Analytics:
// Create the tracker
ga('create', 'UA-XXXXX-Y');
// Fire off a pageview
ga('send', 'pageview');
// Include the ecommerce plugin
ga('require', 'ecommerce', 'ecommerce.js');
// Initialize the transaction
ga('ecommerce:addTransaction', {
id: '1234abc', // Transaction ID*
affiliation: 'Tech Shirts', // Store Name
revenue: '52.19', // Total
shipping: '10', // Shipping
tax: '3.22' // Tax
});
// Add a few items
ga('ecommerce:addItem', {
id: '1234abc', // Transaction ID*
sku: 'TSHIRT-12A', // Product SKU
name: 'Analytics Wizard', // Product Name*
category: 'Men\'s Shirts', // Product Category
price: '12.99', // Price
quantity: '1' // Quantity
});
ga('ecommerce:addItem', {
id: '1234abc', // Transaction ID*
sku: 'TSHIRT-36B', // Product SKU
name: 'Best Developer', // Product Name*
category: 'Women\'s Shirts', // Product Category
price: '12.99', // Price
quantity: '2' // Quantity
});
// Send off the transaction
ga('ecommerce:send');
出于某种原因,如果用户刷新页面,分析团队已决定两次记录相同的事务.
鉴于事务ID是相同的(它显然代表相同的事务,为什么要重复它?),记录同一个事务两次似乎不合逻辑.
这是预期的行为,因为它没有记录? GA团队真的希望每个用户都必须编写代码来防止重复吗?
最佳答案 这是预期的行为.这使您可以发送否定交易以取消购买.您需要修改页面代码,使其不包含重新加载时的电子商务跟踪.