[VTEX Legacy] How to set up an add to cart click trigger in Google Tag Manager

You may already have an Add to Cart trigger set up in your Google Tag Manager container, see here on how to check.

There are different ways to set up an Add to Cart trigger in Google Tag Manager, in this article we show how to set it up using the Click trigger.

You may already have an Add to Cart trigger set up in your Google Tag Manager container, see here on how to check.

How does the Add to Cart Click trigger work?

  • This specific trigger will fire every time a visitor clicks on an add to cart button on your website.
  • To specify the add to cart button clicks we need to enter the specific html class or id of the add to cart buttons.

  1. Go to your Google Tag Manager account and click on Triggers from the left-hand menu.

2. Click on “New” to create a new trigger.

3. Click on Trigger/Acionador configuration.

4. Click on “All Elements” under the “Click” section.

5. Select “Some Clicks”.

6. Now we need to go to your website to find the appropriate click class from your Add to Cart button.

  • Go to a product page on your website.
  • Right click on the Add to Cart button.
  • From the dropdown menu select “Inspect”.

  • In the DevTools window that opens, the html element is already highlighted.
  • Look for the “class” attribute.

  • In this specific case we will use the “buy-button” class.
  • Make sure that the class you select is unique to the add to cart button.

7. Go back to Google Tag Manager and enter the class in the trigger conditions.

  • Make sure that the other conditions are set to “Click Classes” and “contains” as shown in the screenshot.

8. Enter a name for your trigger.

9. Click on “Save” to save your trigger.

10. Don’t forget to Publish your container to submit the changes.

If you have other Add to Cart buttons, for example in the product quick view on the home page or the search results page, make sure to check whether they have the same button class that you set up.

If they don’t, you need to set up another trigger, using the same instructions as above from the beginning, and add the different class in the Trigger conditions.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.