Skip to main content
Benjamin at GROWTH Croissance
Contributor IV
Contributor IV
July 10, 2021
Solved

AddToCart Snippet on Shopify Collection Pages

  • July 10, 2021
  • 12 replies
  • 1419 views

Hi everyone,

Is there a way to use the AddToCart Snippet on Shopify Collection Pages and more generally on page with many Product displayed ?

I guess that the problem is more with the Product Viewed Snippet who collect the informations about the product that are used by AddToCart from what I understood…

Thanks for your help

    This topic has been closed for replies.
    Best answer by David To

    Hello @Benjamin at GROWTH Croissance,

    Great question!

    Your assumption surrounding the limitations of the Viewed Product snippet and how it interacts with multi-product pages is correct. Klaviyo’s Add to Cart function triggers an event when a customer clicks on the add to cart button on your product pages. Because this code works in tandem with the Viewed Product snippet, the Add to Cart code is able to leverages the Viewed Product snippet to identify the product details on what item has been added by your customer. Klaviyo’s default implementation of the Viewed Product and Add to Cart codes are meant to be used on a product page where it would identify the individual product. 

    Both the Viewed Product and Add to Cart codes snippets are Track calls, that take advantage of Klaviyo’s Track and Identify API. As such, it wouldn’t be impossible to create your own custom Track calls meant to be used on a collection’s page or a multi-product page to attain similar functions. For this, I would recommend working with a developer to build out this functionality or finding a Klaviyo partner who can assist in creating this function. I would also suggest using and reviewing the following resources Klaviyo offers on APIs and custom work:

    Thanks for being a member of the Klaviyo Community!

    David

    12 replies

    Akselpd
    Active Contributor I
    Active Contributor I
    November 7, 2021

    Hi @Dov,


    Unfortunately, I don’t get it. I have substituted my code with the one above you have provided.

    Besides, that I don’t see the classes from the source of my product page. 
    Can you, please, share with me what they are? 

    Yours,
    Alex
     

    Yours, Alex
    Dov
    Klaviyo Alum
    November 8, 2021

    Hello @Akselpd,

    Thanks for your follow-up post.

    Basing my judgement on the screenshot from your other post, that snippet should include all of the necessary classes. Since we don’t investigate individual accounts in the community, and you’re still experiencing difficulty getting the Added to Cart event to fire, I advise contacting Klaviyo support to have them take a closer look at your specific account to ensure the classes for your button and the Added to Cart snippet align. I also recommend reviewing the pre-requisites below to ensure you’re meeting these criteria required to fire the Added to Cart event. 

    1. Ensure you have a match between the id or class of the button and the id or class of the Added to Cart snippet
    2. If there are multiple classes being used, ensure all classes are separated by a period
    3. Ensure that you have Viewed Product tracking installed above the Added to Cart snippet in the code
    4. In order to track an Added to Cart event, the browser adding the item must have already been cookied or self-identified i.e. through previously filled out a Klaviyo form, clicking through a Klaviyo email or self-identified using a UTM parameter
    5. Once all of the above conditions are met, you can test the Added to Cart functionality by adding an item to your cart from a cookied browser

    Thanks for being a member of our community! 

    DD