How to Trigger Shopify Web Pixel for Custom Add to Cart Button in JavaScript?
I’ve added a custom "Add to Cart" button using JavaScript instead of Liquid, but I noticed that Shopify's Web Pixel tracking is not capturing the event when this button is clicked. However, the default Shopify "Add to Cart" button is working fine and triggers the Web Pixel event properly.
I’ve identified two possible approaches to solve this issue:
1️⃣ Manually trigger the event so that the Web Pixel function can track my custom button click just like Shopify’s default button.
If this is the recommended approach, how can I manually trigger Shopify's Web Pixel event for "Add to Cart" from JavaScript?
2️⃣ Call an API separately to handle Web Pixel tracking only for my custom button, while leaving Shopify’s default button tracking unchanged.
Would this approach be better, or is it redundant?
I’d appreciate any guidance on which approach is better and, if possible, how to manually trigger the Shopify Web Pixel event in JavaScript for approach #1.
Thanks in advance! 🙌
2 Replies
@evidanary
Hello,
This question would probably be better asked to the Shopify community