Solved

Added to Cart Trigger for non-Product Pages & additional metadata

  • 3 July 2023
  • 6 replies
  • 274 views

Badge +2

I’ve added the “Added to Cart” event into my Shopify store per Klaviyo’s instructions (using Snippet #3 since the default snippet didn’t work for me). However, it seems like it only tracks items that were added from the product page.  

  1. Is there a way to track “added to cart” on non-product pages like the homepage, collections pages, etc?  
     
  2. Is there additional code for snippet 2 and 3 to capture additional data such as quantity added, discounted price, etc?  

Thanks,

Yvonne

icon

Best answer by David To 7 July 2023, 20:30

View original

6 replies

Userlevel 7
Badge +36

Hi @Yvonne ecommerce!

May I ask where you added the snippet? In the Help Center article, there are two options - the Custom Liquid of your default product page, or your site’s theme.liquid file.

 

If you paste the snippet in the custom liquid of your default product page, it will only be applied to product pages, so you may have to add it to the custom liquid file of your other types of pages (homepage, collections, etc.).

 

Customizing the added to cart snippet would constitute a custom use case that is beyond the scope of support/community, but you’re always welcome to reach out to one of our wonderful Official Klaviyo Partners for extra development help!

Thanks for using the Community!
- Brian

 

Badge +2

Hi Brian,

 

Thanks for responding. I tried all options:

  1. (Current) Adding the snippet to custom liquid of product pages - worked when using snippet 3 but only on product pages.
     
  2. Adding snippet to theme.liquid file - did not track “add to cart” events upon testing, so I removed it.
     
  3. Adding snippet to custom liquid block on other pages like homepage, collections page, etc - did not track “add to cart” events, so I removed.

The default instructions from Klaviyo only says add the snippet to product pages. I wish Klaviyo had a more comprehensive solution for all add to cart events on the site.

 

Thanks,

Yvonne

 

 

Userlevel 7
Badge +60

Hey @Yvonne ecommerce,

In my experience, I’ve seen users successfully implement an add to cart function to non-product pages. Though, it does require some custom code in order to function correctly. 

In an oversimplified explanation, the traditional add to cart function works by recognizing when the add to cart button is clicked. This in turn would record an event while leveraging the viewed product event tracking on the page to pass along the product details. 

On non-product pages, a viewed product snippet isn’t available to share those product details. In fact, the add to cart snippet is fairly easy to install. It’s how to record and pass along the details of the page that would be trickier. 

I’ve previously explained a bit of this in a past Community post which I’ve included below:

Overall, triggering an add to cart event on non-product pages is achievable. However, it may require some help from a developer as it involves reviewing your site code and ensuring the codes align with one another while triggering a custom event. As @Brian Turcotte mentioned, if you don’t have a developer available, we would encourage you to reach out to our large network of Klaviyo Partners who can offer their assistance. 

David

I am also adding the snippet 1 or 2 on theme.liquid file but the error it throws is “item is not defined” as mentioned in the following screenshot code i.e 

if i take out the item then everything is good. but then no data for product

@David To please respond how can i define the item, thank you

Userlevel 7
Badge +36

Hi @adnansandhila!

I see that you also posted this question in another Community thread, so for the sake of visibility and organization, I’m going to link to that here:

 

Best,

Brian

Reply