An outdated Klaviyo tracking script installed on Shopify stores before July 2024 may cause Klaviyo Add to Cart events to be fired erroneously.
As Audiences sends events for each Klaviyo Add to Cart event, this may also result in erroneous Audiences Add to Cart events to be emitted.
This issue affects your integration if either of the below occurs:
- numerous "Add to Cart" events are fired in succession for a Klaviyo profile when a shopper adds an item to cart. This may also result in add to cart events being fired with no items or with a price of 0.
- Add to Cart events are fired for a profile even though they have only viewed a product and have not added to cart.
Please note that even with multiple add to cart events firing, only the first one will trigger a flow, as long as your flow has a "has not been in flow in X days" filter.
Why is this happening?
On your Shopify store, you may have added the following code to product pages to support add to cart tracking (provided as part of Klaviyo documentation, which is located here)
if (`${window.location.origin}/cart/add.js`
.includes(res.url)) {
addedToCart()
}
An easy way to identify whether you have this script installed, is searching for "cart/add.js" inside your "Elements" under Devtools. If you are able to identify a script that looks like the snippet of code above, you have the outdated script installed.
This snippet of code results in add to cart events being sent erroneously, for example - executing multiple times when someone adds an item to cart.
Klaviyo has recently updated it's documentation to resolve this issue, but for merchants that onboarded onto Klaviyo before July 2024, this issue continues to be present.
In Klaviyo's documentation (as of 4th July, 2024), it specifies the code should actually be
if (`${window.location.origin}/cart/add.js`
.includes(res.url) && res.url !== '') {
addedToCart()
}
Note the addition of the && res.url !== '' code in the code provided by Klaviyo.
Without that check, duplicate, unnecessary add to cart events will be sent through for the non-Audiences Add to Cart (ATC) event.
How do I resolve this issue?
To resolve this issue, you can either:
- Migrate from Klaviyo's manual snippet tracking to their server side tracking.
Klaviyo has extensive documentation on how to migrate to their server side Add to Cart tracking here: https://help.klaviyo.com/hc/en-us/articles/28709780787355 elithe need for snippets to be used. Instant Audiences' native Add to Cart tracking will kick in if you migrate to Klaviyo's server side tracking which does not rely on manual scripts.- Klaviyo has extensive documentation on how to migrate to their server side Add to Cart tracking here: https://help.klaviyo.com/hc/en-us/articles/28709780787355
- Or, if for any reason you wish to keep the manual script tracking, please update your Klaviyo snippet to match the latest Klaviyo documentation.
-
- The newest snippet is located under "Add the snippet to your site".
-