Skip to main content

Hello, Klaviyo team!

Adrian here, 

I’m trying to set up the add to cart snippet in my store and when I add the code the action doesn’t show up in my analytics after testing. 

 

My ID:

 

I’ve added this into as instructed but I’m still seeing no results:

 

Hi @Ady,

Thank you for sharing your question with the Klaviyo Community.

Since there are a variety of things that could be happening here, I recommend checking out my post in the thread below, it’s the last post at the bottom that takes you through resolving Added to Cart (even if you’re not using Turbo Theme).

 

Please do let us know if you’re still having trouble after reviewing the thread.

Thanks and have a great day.


Hi @Ady,

Thank you for sharing your question with the Klaviyo Community.

Since there are a variety of things that could be happening here, I recommend checking out my post in the thread below, it’s the last post at the bottom that takes you through resolving Added to Cart (even if you’re not using Turbo Theme).

 

Please do let us know if you’re still having trouble after reviewing the thread.

Thanks and have a great day.

 

Thank you for your response.

But as you can see from my screenshot, we have in my button “add to the cart” both ID and Class.

Which code I have to use, could you write me the correct code from this screenshot?

I even tried all the ways and ID and CLASS, none work.

I read everything you wrote there but it doesn't help me I just need the correct code and I can't generate it because I have both, ID and Class

Thank you in advance :)

 


Hey @Ady,

Thanks for providing that screenshot. Since it looks like your add to cart button for your theme is defined by an ID then you should be able to use the default instructions highlighted in the How to Create a Custom "Added to Cart" Event for Shopify article to install the custom Add to Cart code to your site. Because your button has an ID, you would not need to use the alternate class notion installation method. 

As detailed in that article the base code you’ll use for the Add to Cart installation is:

<script type="text/javascript">
var _learnq = _learnq || r];
document.getElementById("AddToCart").addEventListener('click',function (){
_learnq.push(q'track', 'Added to Cart', item]);
});
</script>

Also, as Dov had mentioned earlier in the Community Post he mentioned, you’ll want to make sure that the base code provided above is formatted accurately to be referencing your theme’s button’s ID. You’ll want to format the above default code to replace the “AddToCart” to match whatever ID your theme’s button is using; in this case it seems like it would need to be “AddToCart-product-template-2”

I would also recommend taking a look into the following Community posts on this same topic to see if any of them can provide you more insight into resolving your issue. Other members of the Community also highlighted that not having the Viewed Product/Web Tracking code installed and/or not having their browsers cookied when testing were other reasons that their Add to Cart event were not being recorded.

Hope this helps!

David


Hey @Ady,

Thanks for providing that screenshot. Since it looks like your add to cart button for your theme is defined by an ID then you should be able to use the default instructions highlighted in the How to Create a Custom "Added to Cart" Event for Shopify article to install the custom Add to Cart code to your site. Because your button has an ID, you would not need to use the alternate class notion installation method. 

As detailed in that article the base code you’ll use for the Add to Cart installation is:

<script type="text/javascript">
var _learnq = _learnq || a];
document.getElementById("AddToCart").addEventListener('click',function (){
_learnq.push(n'track', 'Added to Cart', item]);
});
</script>

Also, as Dov had mentioned earlier in the Community Post he mentioned, you’ll want to make sure that the base code provided above is formatted accurately to be referencing your theme’s button’s ID. You’ll want to format the above default code to replace the “AddToCart” to match whatever ID your theme’s button is using; in this case it seems like it would need to be “AddToCart-product-template-2”

I would also recommend taking a look into the following Community posts on this same topic to see if any of them can provide you more insight into resolving your issue. Other members of the Community also highlighted that not having the Viewed Product/Web Tracking code installed and/or not having their browsers cookied when testing were other reasons that their Add to Cart event were not being recorded.

Hope this helps!

David

Regards David,

I did the copied applied code

Still my Metrics do not recognize

Web Tracking is all nicely furnished I don't understand what the problem is anymore

Thank you in advance :)


Hey @Ady,

The message you are receiving of “This flow requires setting up a special “Added to Cart” metric.” would indicate that Klaviyo has not yet recorded any Add to Cart event. 

To allow Klaviyo to recognize this event, after installing the code, have you gone through and cookied your browser to test the add to cart functionality to push this event to Klaviyo as mentioned in this suggested Community Post?

You can cookie your own browser with your desired email by following these steps:

  1. Navigate to your website/homepage in an incognito browser
  2. Add the following to the end of your store URL, replacing example@gmail.com with your email address:
    ?utm_email=example@gmail.com
    • Example URL: wwww.ExampleWebsite.com/?utm_email=example@gmail.com
  3. After you reload the page your browser should be cookied with your desired email address, which would create a profile within Klaviyo
  4. Search in Klaviyo for your email address

 

I hope this helps resolve the issue. If not, I recommend reaching out to support to have a closer look at your website to provide next steps. Let us know how this goes and what the solution was to share with the rest of the Community.

Thanks and have a great day.

David


Reply