How can i get the add to cart event /

Shopify Partner
46 0 4

Is there any way I can log when the user click add to cart button ? I am creating an app which injects a script using scriptTags api. Any way I can listen for that from the script I loaded?

Shopify Partner
1837 210 421

You can attach your click event to all potential add to cart buttons. You can match on specific CSS classes.


Another alternative would be to intercept the AJAX call to add to cart endpoints, execute your piece and forward the request further. Should be used with care.

Sergiu Svinarciuc | CTO @
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to or our blog
New Member
1 0 0

Hi Segiu - how would you go about listening for the AJAX call? Would it be something along the lines of onAjaxSuccess? Thanks in advance!


Hi @tsuj,
You can found an ajax success event on the theme.js code.
Please contact me on my email to implement it.

Founder of Shopify agency -
Contact me on: