You will learn
Learn how to migrate from Klaviyo’s existing Added to Cart event for Shopify (enabled via a code snippet) to the new Added to Cart event, which syncs via a Shopify Server Pixel. When migrating, you can also enable new tracking events for identified users such as Viewed Collection and Submitted Search.
These new Shopify Pixel events are branded with a Shopify icon in Klaviyo, while events enabled by a Klaviyo snippet have a gear icon.
Before you beginBefore you begin
Added to Cart event data synced via Server Side Pixel cannot be customized. To learn what data is included with the new event, consult our Shopify data reference.
Based on your Customer Privacy settings in Shopify, Klaviyo may not track onsite events for visitors to your Shopify store in the EU, EEA, UK and Switzerland, unless they have provided consent.
Why migrate?
There are many reasons to migrate, including:
- The new Shopify-branded event syncs server-side, meaning site visitors are more likely to be identified and track events.
- The new event includes more top-level metadata than the snippet event, including variant info, SKUs, item quantity, and links to the variant added to the cart.
- The new event will be actively maintained by Klaviyo going forward, with future enhancements added directly.
- Enabling the new event does not require a code snippet.
We recommend migrating in the following order (as detailed in this article):
- Enable our new Added to Cart tracking.
- Update segments, flows, and more in Klaviyo.
- Remove your old Added to Cart snippet.
Please note that we are not currently deprecating our Added to Cart snippet.
Enable new Added to Cart trackingEnable new Added to Cart tracking
- In Klaviyo, select your account name in the lower left.
- Click Integrations.
- Select Shopify from the list to be brought to the integration settings page.
- Under Onsite Tracking, select Get started in the blue callout.
- In the modal that appears, Behavioral events will be checked by default. Click Save. This includes Added to Cart, Viewed Collection, and Submitted Search.
- Log in to Shopify if prompted. Review the permissions and click Update app.
- In the confirmation modal, select Update integration.
- You’ll be brought back to Klaviyo and should see a green success callout.
You should now start seeing Shopify-branded Added to Cart events tracked in your account.
Update segments, flows, and more in KlaviyoUpdate segments, flows, and more in Klaviyo
You should now replace all existing usage of the unbranded Added to Cart metric in your Klaviyo account with the new branded event.
SegmentsSegments
- In the Lists & segments tab, look for segments where you’ve used the unbranded Added to Cart metric.
- Edit each segment, adding an OR clause mirroring your original but using the Shopify-branded Added to Cart metric. For example, the segment below includes those who added to cart at least once in the last 30 days, tracked by either metric.
Flows
Are you using the unbranded Added to Cart metric in an abandoned cart or other flow? To replace them:
- Find the flows where you’re using Added to Cart.
- Clone these flows and name them something descriptive.
- In the new flows, replace the flow trigger with the Shopify-branded Added to Cart event.
- Update any variables needed.
- Send a test email for each new flow to make sure that everything looks good and that no variables need to be updated. If you were using our default snippet, all existing variables should be the same, except that the price is now a numeric value instead of a string (e.g., 4 vs. $4.00). You can add currency formatting like this:
{% currency_format event|lookup:'Price'|floatformat:2 %}
Additionally, please note that the new Added to Cart event does not currently include other items already in the cart; it just tracks a single item. - Turn off the old flows and set the new flows live.
Analytics
If you’re using the unbranded Added to Cart metric in any analytics, such as custom reports, you should build new custom reports
Remove your Added to Cart snippetRemove your Added to Cart snippet
Are you using your existing Added to Cart event in a Klaviyo product feed? This means that you selected Products a customer has added to cart in the feed builder.
If so, you should not remove your snippet. This is because we currently recommend using the old event with product feeds. You can use the new event for flows, segments, etc. If you are not using the event in a product feed, continue on.
You may have added your snippet in one of two ways:
- If your store has custom liquid blocks, your snippet will be in a custom liquid block.
- If your store does not have custom liquid blocks, your snippet will be in your theme file.
To remove your snippet:
- In Shopify, navigate to Online Store > Themes.
- Find your theme and click Customize.
- If your store has custom liquid blocks:
- At the top of the page, click the Home page dropdown.
- Select Products > Default product to be brought to your default product page.
- Find the custom liquid block you used for your Added to Cart snippet. There are multiple code snippets you may have used; look for the line
_learnq.push(['track', 'Added to Cart', cart]);
if you aren’t sure. - When you have the block selected, click Remove section.
- Click Save.
- If your store does not have custom liquid blocks:
- Click the three dots at the top and select Edit code.
- Open the theme.liquid file.
- Find your Added to Cart snippet code.
- There are multiple code snippets you may have used; look for the line
_learnq.push(['track', 'Added to Cart', cart]);
if you aren’t sure. - Delete the snippet, starting with the opening <script> tag and ending with the closing </script> tag.
- Click Save.
You have now removed your Added to Cart snippet.
TroubleshootingTroubleshooting
Are you not seeing new Added to Cart events appear in your account?
It may take some time for profiles previously cookied by Klaviyo via the old method to be identified by Shopify.
With the new Added to Cart tracking (as well as with Shopify Viewed Collection and Submitted Search events), profiles will be identified if they do one of the following:
- Submit a Klaviyo form.
- You must have enabled syncing profiles from Klaviyo to Shopify for this to work.
- Submit a Shopify form.
- Enter their information on the checkout page.
- Log in to their Shop account on checkout page.
- Log in to their customer account on the store.
You can complete one of the items above in order to test your Added to Cart tracking.
We are working to expand functionality to include other Klaviyo identification methods (such as tracking from clicking on an email) to the new Shopify Added to Cart event.
OutcomeOutcome
You’ve now migrated from Klaviyo’s manually-enabled Added to Cart tracking to our new, server-side Added to Cart tracking in Shopify.
Additional resources