I'm trying to add enhanced ecommerce tracking to my store. I managed to get it to track when products are viewed by including this on viewprd.asp:
<script> ga('ec:addProduct', { 'id': '<%=pSku%>', 'name': '<%=pMainProductName%>', 'brand': '<%=BrandName%>' }); ga('ec:setAction', 'detail'); </script>
|
And then to track when an item is added to the cart, I added this at the end of the checkproqty() function from pcValidateViewPrd.asp:
ga('ec:addProduct', { 'id': '<%=pSku%>', 'name': '<%=pMainProductName%>', 'brand': '<%=BrandName%>', 'price': <%=pPrice%>, 'quantity': fname.value }); ga('ec:setAction', 'add'); ga('send', 'event', 'UX', 'click', 'add to cart');
|
Now I'm trying to get it to track when an item is removed from the cart. However, on the viewcart.asp page all of the cart data is handled by angular.js.
I'm not sure how to reference the cart variables. For the previous two events, I'm having it output the actual variables from ASP into the script. For this one, it's seeming like I'm going to need to have it reference the angular.js cart object and then the specific item from the cart.
I figure it would probably look something like this:
function removeCartItem({{shoppingcartitem}}) { ga('ec:addProduct', { 'id': '{{shoppingcartitem.sku}}', 'name': '{{shoppingcartitem.description}}', 'price': {{shoppingcartitem.UnitPrice}}, 'quantity': {{shoppingcartitem.quantity}} }); ga('ec:setAction', 'remove'); ga('send', 'event', 'UX', 'click', 'remove from cart'); }
|
Any chance anyone knows a good way to accomplish this?
|