Track Add to cart and checkout initiated

Hey,

I’m currently building a tracking software for Shopify stores.

I want to provide a JS script that will track the actions visitors perform on the store. This script will be added to their theme.liquid page.

The issue I’m facing is that I do not know how to universally track add-to-cart clicks. In general, it would be pretty easy to just add the tracking function in the onClick of the add to cart button but the issue is that I do not know how to do that from the JS tracking script. I would need to know the ID of the add to cart button.

But since this JS tracking script that I want to provide should work on any store/theme there is no way for me to know the ID of the add-to-cart button.

Does anybody know a way around this? Should I use something like Google Tag Manager? Or is there a way in Shopify to identify the add-to-cart button?

I would really appreciate your help on this :slightly_smiling_face:

Kind regards,

Noah

Could you possibly perform whatever operations you wanted in response to Cart.js events?

Thank you again for your reply. I have now just implemented my operations in the onClick and it works as intended. In the beginning I wanted to avoid this but Im fine with it now that I thought about it a little bit more.

Thanks for taking the time again to help me out!
Hope you have a great rest of your day.
Kind regards

1 Like