2014-12-04 42 views
1

我目前正在實施Google Analytics增強型電子商務。當我在我的開發環境中購買某些東西時,我檢查了我的開發人員分析購物行爲,並且我僅查看了所有會話和會話中的交易值,但兩者之間沒有任何值。我的代碼如下。在每個ga('ec')之前或之後,我有時會發起事件進行正常分析。我的代碼有什麼問題嗎?增強型電子商務唯一記錄setAction

// 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'); 

回答

2

對於一般的印象,你需要刪除「細節」

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/

相關問題