ProductCart E-Commerce Solutions Homepage
Forum Home Forum Home > ProductCart > Using ProductCart
  New Posts New Posts RSS Feed - Analytics enhanced ecommerce events w/ angular
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Analytics enhanced ecommerce events w/ angular

 Post Reply Post Reply
Author
Message
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Topic: Analytics enhanced ecommerce events w/ angular
    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?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.