javascript - How to specify what "list" the product was added to cart from? Enhanced Ecommerce -
trying implement google analytics enhanced ecommerce tracking website.
how specify "list" product added cart from?
here standard tracking code adding product basket:
// called when product added shopping cart. function addtocart(product) { 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'); ga('send', 'event', 'ux', 'click', 'add cart'); // send data using event. } there no functionality specify name of products list button "add cart" clicked.
there must this:
ga('ec:setaction', 'click', {'list': 'search results'}); but works 'click' action, (not 'add'). (as per https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#(product action) )
moreover need specify position of product in list. any ideas?
list variable in actionfield valid click , detail action. if want track customer journey, have merge click , add 1 logical event.
so if can add directly list , want tie data in ua, have soem little workaround like:
function addtocart(product) { 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', 'click', {'list': 'search results'}); ga('send', 'event', 'automatic', 'click', 'add cart',{'noninteraction': 1}); // send data using event. 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'); ga('send', 'event', 'ux', 'click', 'add cart'); // send data using event. }
Comments
Post a Comment