Hi Klaviyo team!
i was setting up the added to cart event on one of my stores and when i add the snippet code in product.liquid with my ID, the added to cart doesn’t show in my metrics!
i tried adding a product to cart but nothing happened
Hi Klaviyo team!
i was setting up the added to cart event on one of my stores and when i add the snippet code in product.liquid with my ID, the added to cart doesn’t show in my metrics!
i tried adding a product to cart but nothing happened
If the "Added to Cart" event is not appearing on your analytics, it could be due to several reasons. Check if the event tracking code is correctly implemented on your website, verify if the event is firing correctly, and ensure that there are no issues with the analytics platform configuration or integration.
Hi
Thank you for sharing this information with the Klaviyo Community.
In addition to taking into consideration the points made by
Also, you must already have Viewed Product tracking installed in order for the Added to Cart event to appear and function . The Viewed Product snippet must be installed above the Added to Cart snippet in the code for your website. We have more details in our article on this topic here.
Thanks, and have a great day.
Hi
One useful approach to testing or debugging things like this is adding some logging to the script to narrow down possible causes, or locate the specific portion of the code that is not working as expected. In this case, for example, it could be helpful to add a console.log statement above where you reference _learnq… This would effectively make the script say, “Listen for the click of a button with this ID and when that is observed, first log some text to the console, then make the track call to Klaviyo.”
If you add this code and then test it - and watch the dev console to see if this logs out - you’ll be able to determine if your event listener is working as expected. If the statement does log, it suggests that the event listener is properly configured. And if that’s the case, the most likely reason for the track call not going through is that you are trying to make that call, but without having a known identity to Klaviyo. In other words, the code could be perfectly fine, but if Klaviyo’s cookie doesn’t know who you are, that track call won’t get sent (by design).
If you find yourself in this scenario, I recommend using this approach to identify yourself and then retry. Specifically, you can add a param to the URL that says “utm_email=” followed by your email. That will cause you to get cookied and then I would expect your track call to go through as expected (provided that your event listener is working, as demonstrated by the console logging mentioned above).
Phew, that was long, but hopefully helpful!
The snipped you’ve used looks OK, but I’m not sure about the ID you’ve used in the snippet. Can you please provide a screenshot of the HTML from your “add to cart” button in Shopify? Maybe you’ve used the wrong ID.
Let’s start with that and see if we’ll find a way to troubleshoot this.
yeah sure!
here is a screenshot of my ATC button HTML
Your event listener will function as intended if you add this code, test it, and then keep an eye on the dev console to see if this logs out. If the statement really logs something, it can mean that the event listener is set up correctly. If so, the fact that you are attempting to make the track call without first providing Klaviyo with your known identify is the most likely cause of it failing.
If the statement logs, it indicates correct configuration of the event listener. In the scenario where a track call isn't successful, it's probable that the call is made without a recognized identity in Klaviyo. Essentially, the code might be sound, but without a known igg game user identity in Klaviyo's cookie, the track call won't be transmitted intentionally.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.