Troubleshooting Added to Cart tracking

read
Last updated at:

Before you begin

Added to Cart tracking is enabled via a JavaScript code snippet added to your site. For some ecommerce platforms, Added to Cart events are tracked automatically. For other ecommerce platforms, it must be manually added to your site.

Before consulting this guide, make sure you:

  • Enable Added to Cart tracking, if it was not added automatically through your integration.
  • Enable Klaviyo’s “Active on Site” JavaScript, known as Klaviyo.js, in order for Added to Cart tracking to work. Learn how in the "Active on Site" section below.
  • Enable Viewed Product tracking if it is not automatically enabled by your integration.

BigCommerce and Shopify users

If you are using BigCommerce or Shopify, Viewed Product tracking is required in order for Added to Cart tracking to function properly. Make sure to follow the steps in the integration setup guides linked below in order to properly enable Viewed Product tracking.

If you are experiencing issues with Viewed Product tracking, please see our guide on troubleshooting Viewed Product tracking.

The following ecommerce integrations support Added to Cart tracking, and it works as follows:

If you’re using an ecommerce platform without a pre-built Klaviyo integration, or a custom platform, learn about how to enable Viewed Product and Added to Cart tracking on our Developer site.

Test Added to Cart tracking

To test that your Added to Cart tracking is set up properly, follow these steps:

  1. Navigate to your website
  2. On your homepage, add the following to the end of the URL, replacing example@gmail.com with your email address:
    ?utm_email=example@gmail.com
    After modifying the email address used in the example, add it to the end of your site's URL and visit your site in any browser.
  3. Reload the page
  4. Navigate to a product page on your site with a product that is in stock
  5. Click the “Add to Cart” button on the page
  6. Search in Klaviyo for the email address you used in step 2
    The searchbar can be found in the top right of Klaviyo where you can search for profiles by email address.

You should see that a Klaviyo profile has been created for you (if one didn't exist already) and that an Added to Cart event has been tracked on your activity feed.

To see a feed of all Added to Cart metrics over time:

  1. Navigate to the Analytics tab of your account 
  2. Click into Metrics
  3. Filter by Added to Cart to view tracked data in an activity feed, activity map, charts, best people, and cohort reports
    At the top of the Metrics page there is a searchbar where you can search for different metric by name.

Once you’ve reviewed the troubleshooting scenarios below and made changes, you should test your tracking again to make sure it’s working correctly. 

Troubleshooting scenarios

Review the following questions in order to diagnose the cause of your Added to Cart issues. Note that some steps are general, and others depend on what ecommerce platform you are using.

Have you enabled Klaviyo’s Active on Site tracking?

In order for Added to Cart tracking to work correctly, you must first enable Klaviyo’s Active on Site tracking which allows your customers to be cookied. Active on Site tracking is enabled via the addition of a JavaScript snippet (known as “Klaviyo’s onsite JavaScript” or “Klaviyo.js”) to your site.

Klaviyo adds Klaviyo.js automatically during the integration, though some integrations require that you check a setting to enable it. Learn about your specific ecommerce platform and how to test that Klaviyo.js is working:

  1. Shopify
    Klaviyo.js is added automatically through the integration or through the Klaviyo app embed in Shopify, if you enable it. If you integrated before April 19, 2022, you did not have the Klaviyo app embed option but can now enable it at any time. Learn more about the app embed and onsite tracking for Shopify
  2. WooCommerce
    Klaviyo.js is added automatically when you integrate with WooCommerce, and you can make sure that you’ve completed all steps by reading our WooCommerce integration guide. To test your onsite JavaScript, click the account dropdown in your Klaviyo account and click Setup Web Tracking. Then, find the step where you can enter your site URL in the box, and follow the instructions to test your tracking.
  3. BigCommerce
    Make sure you’ve checked the option on your integration settings page to Automatically add Klaviyo onsite JavaScript. Then, follow the steps to test your onsite JavaScript
  4. Magento 2
    Klaviyo.js is added automatically when you integrate with Magento 2, and you can make sure that you’ve completed all steps by reading our Magento 2 integration guide. To test your onsite JavaScript, click the account dropdown in your Klaviyo account and click Setup Web Tracking. Then, find the step where you can enter your site URL in the box, and follow the instructions to test your tracking. 
  5. PrestaShop
    Klaviyo.js is added automatically when you integrate with Magento 2, and you can make sure that you’ve completed all steps by reading our PrestaShop integration guide. To test your onsite JavaScript, click the account dropdown in your Klaviyo account and click Setup Web Tracking. Then, find the step where you can enter your site URL in the box, and follow the instructions to test your tracking. 

For Shopify users who integrated before April 19, 2022 and current BigCommerce users: Have you installed Klaviyo’s Viewed Product tracking?

If you integrated with Shopify before April 19, 2022, but did not add the Viewed Product snippet to your site, you can now do so easily via the app embed. Once you enable the app embed in Shopify, Active on Site tracking will be automatically removed via the old method and re-added via the new method, along with Viewed Product tracking. Read our article on enabling the Klaviyo app embed in Shopify for more information.

For current BigCommerce integrations, Viewed Product tracking must be manually added to your site using a code snippet in order for Added to Cart tracking can work. The BigCommerce integration guide has steps on how to install Viewed Product tracking for BigCommerce.

Have you recently switched ecommerce platforms?

If you’ve recently switched ecommerce platforms, you’ll need to add both Viewed Product and Added to Cart tracking to your new site. Consult the information in the Before you begin section above to learn about Viewed Product and Added to Cart tracking for your new platform. 

Have you recently updated your store’s theme, or made any other updates to your ecommerce platform?

If you’ve recently updated your store’s theme, you may need to reinstall Klaviyo.js, the Viewed Product snippet, and the Added to Cart snippet on your new theme depending on the platform. Making other updates to your ecommerce platform may also affect the snippets previously added to your site.

To reinstall the Viewed Product snippet for BigCommerce, follow the instructions in the BigCommerce integration setup guide, and for the Added to Cart snippet follow the guide to creating an "Added to Cart" event for BigCommerce.

If you’re using WooCommerce or Magento, or are using the Klaviyo app embed in Shopify, but you’ve made changes to your site and now the event isn’t tracking, you should contact Klaviyo support to help diagnose the problem.

For Shopify and BigCommerce users: Is your ecommerce store connected to multiple Klaviyo accounts?

If you have one store connected to multiple Klaviyo accounts, this can cause problems with Active on Site, Viewed Product, and Added to Cart tracking. For instance, if you have a Shopify store integrated with two Klaviyo accounts, and integrated with Klaviyo before April 19, 2022 or are not using the Klaviyo app embed, there might be duplicate Klaviyo.js on your site. Duplicate Klaviyo.js can cause onsite tracking to break.

To check if you have duplicate Klaviyo.js:

  1. Navigate to your main theme file (in Shopify, typically the theme.liquid file). Klaviyo.js looks like this:
    <script type="text/javascript" async="" src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=API_KEY"></script>
  2. If you search for company_id within the file and find it twice (and see two of the snippets shown above) then you have duplicate Klaviyo.js. There will typically be two different API keys after the equals sign, one from each Klaviyo account. 
  3. To make sure the duplicate is removed correctly from your site, please contact Klaviyo support

For Shopify and BigCommerce users: Are you using the correct code snippet for your Add to Cart button?

Both Shopify and BigCommerce require a manually installed code snippet to use Added to Cart tracking, and have alternate snippets depending on how your theme’s “Add to Cart” button works.

Shopify has 3 different snippets that can be installed into your theme depending on which of the following applies to your “Add to Cart” button:

  • No redirects
  • Has a redirect and the button is defined by button ID
  • Has a redirect and the button is defined by button class

You will also need to change the ID or class used in the snippet if your theme uses an ID or class different from the default. Please see our guide on how to create an "Added to Cart" event for Shopify for more information on how to check this.

BigCommerce has 2 different snippets that can be installed into your theme depending on if your “Add to Cart” button has an ID or not.

You will also need to change the ID or class used in the snippet if your theme uses an ID or class different from the default. Please see our guide on how to create an "Added to Cart" event for BigCommerce for more information on how to check this.

For WooCommerce and Magento users: Are you using the most recent version of your integration plugin?

If you are using WooCommerce or Magento, problems with Added to Cart tracking might be related to other issues with your platform’s Klaviyo plugin.

  1. If Added to Cart events aren’t tracking, check to see if the Started Checkout event is tracking by searching for Started Checkout within Analytics > Metrics in Klaviyo. 
  2. If both Added to Cart and Started Checkout aren’t tracking, there may be an issue with your plugin.
  3. Check to see if you are using the most up-to-date version of the plugin for your integration. If needed, update to the latest version within WooCommerce or Magento, or you can download the latest version from the relevant platform’s listing.

For Shopify users who integrated before April 19, 2022: Are you hosting products in your product.liquid file?

The Viewed Product and Added to Cart installation instructions for Shopify (non–2.0 themes) given to users who integrated before April 19, 2022 instructed you to add the snippets to the product.liquid file, which is where products are typically hosted. Depending on your store’s theme, you may host products in a different file (e.g., if you use a page builder like Shogun, GemPages, Pagefly, or Debutify build your product pages). Make sure that your Viewed Product and Added to Cart snippets are added to the same file where your product code is hosted. To learn how to manually install the Viewed Product and Added to Cart snippets on your file, check out our developer portal.

To ensure that the Viewed Product snippet loads first, please make sure to paste the Added to Cart snippet below the Viewed Product snippet.

For Shopify users: Do you require cookie consent for visitors in the EU, EEA, UK and Switzerland prior to permitting onsite tracking?

Based on your Customer Privacy settings in Shopify, Klaviyo may not track onsite events (including Active on Site, Viewed Product, and Added to Cart) for visitors to your Shopify store in the EU, EEA, UK and Switzerland, unless they have provided consent.

Contact Klaviyo support

If you are still encountering issues after consulting this list and testing your tracking, please reach out in our Community or to our Support Team

Additional resources

Learn how to troubleshoot other metrics:

Other resources:

x
Was this article helpful?
13 out of 23 found this helpful