Viewed Product & Add to Cart not working

  • 5 April 2022
  • 3 replies

Badge +2

Hi there,

I can’t seem to figure this out after reading other discussions’ on ATC and Viewed Product. I’ve just added the Viewed Product code and Add to Cart code to my client’s Shopify store but both of these events do not seem to work. Here’s the screenshot of the codes:

(ps. I got the add to cart ID by following these steps)


I’ve also tested it with putting the ? at the end of the store’s url but it didn’t trigger any of these two events. 

Also, the store also has other product pages as shown below. Do I need to insert these codes in all 4 pages?



Please let me know if I’m missing a step or did this incorrectly. Thank you!


Best answer by David To 6 April 2022, 17:14

View original

3 replies

Userlevel 7
Badge +60

Hello @nabilah,

From your screenshots it does appear the Viewed Product snippet is installed correctly. The Add to Cart snippet though, I would advise reviewing further. In my experience when an add to cart button is identified by a numeric value as yours has, chances are these add to cart button IDs are unique. This means they’ll often times have a global class notation associated with this. In this case, you’ll want to reformat and use the alternate code mentioned in the Alternate Snippet for "Add to Cart" Button without a Button ID section of the Guide to Creating an "Added to Cart" Event for Shopify Help Center article.

There’s also been a number of Community topics on this as well which highlights the use of the alternate code snippet when a class notation is defined such as the ones below:

Additionally, since it sounds like despite the Viewed Product snippet being installed correctly and wasn’t triggered when cookieing yourself and testing, I would suggest double checking to make sure you’ve installed the Klaviyo.js correctly and that you also do not have multiple Klaviyo accounts associated with your site. Having multiple Klaviyo accounts connected to a single site is known to cause behaviors such as this since depending which Klaviyo account’s javascript is rendered first, would cause those events to be recorded in those respective accounts. I would recommend taking a look at the following Community post for steps on how to investigate and see if this was the cause to your events not being recoded appropriately: 

If you need further hands on assistance and troubleshooting, I would advise reaching out to your site developer who can further review your site code and troubleshoot. You can also consider reaching out to a Klaviyo Partner for assistance.

I hope this helps!


Badge +2

Hi @David To, thanks for the response.

As per your suggestion, I checked to see if I’ve installed the Klaviyo.js correct and if I have multiple Klaviyo accounts associated by going to view page source. I found three company_id tags as shown in the screenshots above. One has a different company ID and the other two are the same company IDs. Does this mean that there are multiple Klaviyo accounts associate with the website?


Userlevel 7
Badge +60

Hey @nabilah,

I took the liberty of editing your post and removing your screenshots as they displayed your various account’s site/public ID for security purposes. 

If there were any company IDs present on your website that do not align with your own account’s ID, then this would mean you would have multiple Klaviyo accounts associated with your site. As mentioned prior, this is known to cause a variety of issues including events not recording accurately within your desired account. This has to do with whichever account ID gets loaded first will record those viewed product, active onsite, etc. events that’s based on the web tracking. 

I would suggest taking the steps outlined in the previously linked Community post to alleviate this. You can also reach out to our wonderful Support colleagues to have the accidentally created and linked account cancelled if you wish.