Print Page | Close Window

Analytics enhanced ecommerce events w/ angular

Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Using ProductCart
Forum Description: Running your store with ProductCart
URL: https://forum.productcart.com/forum_posts.asp?TID=6110
Printed Date: 27-November-2024 at 1:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Analytics enhanced ecommerce events w/ angular
Posted By: Brett
Subject: Analytics enhanced ecommerce events w/ angular
Date Posted: 28-May-2017 at 11:48pm
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?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net