我目前正在实施Google Analytics增强型电子商务。当我在开发环境中购买东西时,我会检查我的开发分析购物行为,我只看到所有会话和交易会话中的值,但两者之间没有任何内容。我的代码如下。每个ga('ec')之前或之后& ga('send')对我有时会触发事件进行正常分析。我的代码有什么问题吗?
// All values are angular expressions that I've
// double triple checked to make sure they give good values
ga('ec:addImpression', 'detail',{
'id': $location.search().tripToken,
'name': $scope.holds[a].value,
'price': $scope.holds[a].price,
'category' : tileDisable
});
ga('send','pageview')
// Next GA fire a bit later
ga('ec:addProduct', 'checkout', {
'id': $location.search().tripToken,
'name': optionType,
'price': $scope.getOptionPrice(optionType),
'quantity': parseInt($scope.baseInfo.total_travelers)
});
ga('send','pageview');
// A bit later
ga('ec:setAction', 'purchase', {
'id': $scope.userData.option_type,
'affiliation': $scope.userData.token,
'revenue': $scope.userData.option_price * $scope.baseInfo.total_travelers
});
ga('send','pageview');
答案 0 :(得分:3)
对于常见的展示,您必须删除“详细信息”
ga('ec:addImpression' *** REMOVE ,'detail'***,{
'id': $location.search().tripToken,
'name': $scope.holds[a].value,
'price': $scope.holds[a].price,
'category' : tileDisable
});
然后,当点击产品时,您需要添加
ga('ec:addProduct', {
'id': 'P12345',
'name': 'Android Warhol T-Shirt',
'category': 'Apparel',
'brand': 'Google',
'variant': 'black',
'position': 1
});
ga('ec:setAction', 'click', {list: 'Search Results'});
//Remember to add a (non interaction if you wish) event here in order to send the data to GA
ga('send','event','whatever-value');
最后一步是为详细信息页面添加clic(添加到购物车):
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'category': product.category,
'brand': product.brand,
'variant': product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
// Send data using an event again (depends on user interaction)
ga('send', 'event', 'UX', 'click', 'add to cart');
如果您想查看实际示例,请访问官方Google的演示: http://enhancedecommerce.appspot.com/