Search code examples
google-analyticse-commerceprestashopgoogle-tag-manager

GTM enhanced ecommerce : implement Add to Cart function


I'm struggling from weeks now to implement the Add to Cart function with Google Tag Manager on my Prestashop website.

I do have transactions details and impressions pages, but I don't understand how to configure Add to Cart. Following Google instructions, here what I've done :
-For the tag, I just took the same instructions than in Google Documentation. -The trigger: trigger-image

I guess another thing has to be enter instead of "addToCart" field. I tried to trigger the tag with a click event on my addtocart class button, but I just had the data of an event, I never had the "add" action in my data layer.

Where am I wrong ?

I'm working on the basic demo PrestaShop website.

Any help would be really useful !

Thanks


Solution

  • You should call function on cart addition.

    <script>
       function addToCart(product) {
       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
              }]
           }
         }
       });
       }
       </script>
    

    After that you should fix your firing rule: Event name — addToCart, remove all other conditions.