Track Add to cart and checkout initiated

Solved

Track Add to cart and checkout initiated

noah_haub
Shopify Partner
25 2 5

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 🙂

Kind regards,

Noah

Accepted Solution (1)

buildpath
Shopify Partner
59 11 20

This is an accepted solution.

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

Ecom entrepreneur since 2004 | Shopify App developer since 2021 | Shopify merchant and theme developer since 2016

View solution in original post

Replies 2 (2)

buildpath
Shopify Partner
59 11 20

This is an accepted solution.

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

Ecom entrepreneur since 2004 | Shopify App developer since 2021 | Shopify merchant and theme developer since 2016
noah_haub
Shopify Partner
25 2 5

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