Google analytics add to cart tracking

  • Posts: 1119
  • Thank you received: 114
8 years 3 months ago #247772

Hi,

I am looking to add such code and track "Adding a Product to a Shopping Cart" in my GA:

// Measure adding a product to a shopping cart by using an 'add' actionFieldObject
// and a list of productFieldObjects.
dataLayer.push({
  'event': 'addToCart',
  'ecommerce': {
    'currencyCode': 'EUR',
    'add': {                                // 'add' actionFieldObject measures.
      'products': [{                        //  adding a product to a shopping cart.
        'name': 'Triblend Android T-Shirt',
        'id': '12345',
        'price': '15.25',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Gray',
        'quantity': 1
       }]
    }
  }
});

Now I am thinking where should I place this code. In which view?

Same question for "Removing a Product from a Shopping Cart"?

I do not use hikashop GA plugin cause after a lot of tries it doesn't work with me so I use google tag manager....

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 3 months ago #247776

Hi,

There is no view where you can put such code because the "add to cart" can happen anywhere, anytime.
You'll need a custom plugin which will be triggered on the cart events and which should then add some JS code in the page header.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 3 months ago #247847

Hi,

As we use variants on all products, add to cart happens only on product page.
I also do have custom plugin which i use to track sales and i could modify it. Now which hikashop trigger i should use for cart events? OnAfterCartUpdate?

Last edit: 8 years 3 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
8 years 3 months ago #247908

Hi,

Yes, That trigger will be called when a product is added or deleted from the cart.
So that's where I would recommend to add your code to add your javascript to the page.

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum