How can i get the add to cart event /

tsuj
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?

0 Likes
Visely-Team
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 @ visely.io
- 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 visely.io or our blog
codybreene1
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!

0 Likes

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 - Accomplishify.com
Contact me on: M.morek@accomplishify.com
0 Likes