Track this add to cart click

Trying to track this button click (add to cart)

< button type=“submit” title=“Order” class=“action primary tocart” id=“product-addtocart-button”>Order

with this trigger

But i must be doing something wrong since it’s not working (switching to click id is not moving the needle as well).

Thxs

Hello @dave

Click element would be used for object. In this case I can suggest you to use
Click ID or Click Classes instead and match it with parameters from your button.

example:
Click ID - matches - product-addtocart-button

If you aren’t sure what variables are visible for object you are clicking, there is also another method. You can always open debug mode → connect to tested website → go to “Events” instead of tags → select from list action you just did → check variables visible by tag manager

Thxs @jfidala for the fast reply. When checking events there is no click id visable:

Class is changing when element is clicked and I think it’s gone for brief second - but I’ve noticed in console that there is stg.formSubmit with each Add to cart button pressed.

Maybe you can do Form submission trigger instead and set Form URL to starts with"https://www.matthys.net/en/checkout/cart/add/ ?

1 Like

Something similar @jfidala .

Having this click class and using that in the trigger but the tag is not firing :confused:

4

So not sure what’s going wrong? Thxs!

Did you try using this CSS selector?

Click Element matches
#product-addtocart-button, #product-addtocart-button *

When you want to measure clicks on non-link (<a>) elements, you may want to explicitly target children elements as well (using *), otherwise depending on where you click within the button the trigger may not fire.

If it’s a link element you can try to activate the option to “Wait for tags before loading the next page”, sometimes the trigger does not fire unless you activate this option.

1 Like

That was the solution :slight_smile: Thxs

1 Like