Getting started with Klaviyo onsite tracking

Last updated at:

You will learn

Learn about the different ways that Klaviyo can support onsite tracking on your ecommerce site. There are two key types of onsite tracking:

  • Active on Site
    This metric is tracked whenever an identifiable browser visits your website
  • Viewed Product
    This metric is tracked whenever an identifiable browser views a product page on your website (for ecommerce stores)

Active on Site tracking can help segment your contacts based on engagement level, while Viewed Product tracking can enable you to send customers reminders in a browse abandonment flow

Before you begin

Enabling onsite tracking is different for each ecommerce integration. In this article, you will learn how to do this, and who Klaviyo tracks. 

The code snippet for Active on Site is known as Klaviyo’s onsite JavaScript, or “Klaviyo.js”. You do not need to add Klaviyo.js separately if you enabled Active on Site tracking through one of the ecommerce integrations below:

  • Shopify
    Active on Site tracking is added automatically through the integration or through the Klaviyo app embed if its toggled on 
  • BigCommerce
    Active on Site tracking is added when you integrate if you check the setting Automatically add Klaviyo onsite JavaScript in Klaviyo
  • WooCommerce
    Active on Site tracking is added automatically when you integrate
  • Magento
    Active on Site tracking is added automatically when you integrate

If you are using another ecommerce platform, or a custom platform, you can install Klaviyo.js manually.

Because pasting this code requires access to your site's HTML and ecommerce platform, our support team is unable to offer hands-on assistance. If you don't have a developer resource on your team and aren't comfortable adding the code, consider reaching out to a Klaviyo partner for assistance.

Add Active on Site tracking manually

  1. Copy the following Active on Site code snippet, also known as Klaviyo.js:
    <script type="text/javascript" async="" src=""></script>
  2. In Klaviyo, click your account name in the lower left corner and navigate to Settings > API Keys, then note your Public API Key.
  3. Paste the code snippet in the main template of your site. Where you see PUBLIC_API_KEY in the snippet, replace this with your key.
  4. Save and publish your site template. 

Now that you've installed Active on Site tracking, Klaviyo will track whenever an identifiable person visits your website.

Viewed Product tracking

Viewed Product tracking in Klaviyo is specifically designed for ecommerce stores, and can enable you to send customers reminders in a browse abandonment flow. Once Viewed Product tracking is installed, a Viewed Product metric will be recorded whenever an identifiable person views a product page on your website. Enabling Viewed Product tracking is different for each ecommerce platform. If you are not seeing data captured from this metric, double-check that it's installed correctly. 

Learn how to enable Viewed Product tracking for these ecommerce platforms:

Viewed Product tracking is automatically installed through these ecommerce integrations:

Viewed Product tracking can also be added to other ecommerce platforms and custom carts. For instructions on how to do this, head to our guide to adding viewed product tracking for custom ecommerce stores.

Test onsite tracking

After enabling tracking on your site, you can test that tracking is set up properly by following these steps:

  1. Navigate to your website
  2. Add the following to the end of your store url, replacing with your email address:
  3. After you reload the page, search in Klaviyo for your email address

You should see that a Klaviyo profile has been created for you (if one didn't exist already) and that this site visit has been tracked on your activity feed.

To see a feed of all tracked activity for the Active on Site and Viewed Product metrics, navigate to the Metrics tab, under Analytics, in Klaviyo. You can click on each metric to analyze tracked data through an activity feed, activity map, charts, best people, and cohort reports. You can also filter by source - filter by API to see Active on Site and Viewed Product events (these events have a gear icon). 


Who Klaviyo tracks

By enabling basic onsite tracking on your website, you can collect helpful information around browsing activity that can be leveraged to take your owned marketing and business analytics to the next level.

When you add Klaviyo's onsite tracking to your site, we only track the browsing activity of "known browsers" — i.e. browsers that have visited, engaged, and been identified (or "cookied"), at least once before. Klaviyo will not track anonymous browsers.

An example of a subscriber profile when they have engaged with your website before, as Klaviyo does not track anonymous browsers

There are three key ways Klaviyo will be able to identify a site visitor for onsite tracking purposes:

  • If someone has, at some point, clicked through a Klaviyo email to your website
  • If someone has, at some point, subscribed/opted-in through a Klaviyo form
  • If someone has, at some point, logged into your site and you have identify tracking installed

As a result, until you start sending emails with Klaviyo and growing your lists, you probably won't see a lot of tracked onsite activity. Over time, Klaviyo will identify more and more of your contact-base and your onsite tracking data will become more comprehensive.

Leveraging Active on Site tracking

Ways to leverage Active on Site include:

  • Segment your contacts based on engagement level
    By gaining insight into which contacts interact with your website and how often, you can build a more personal communication strategy that drives deeper engagement.
  • Trigger an automated flow email to those that browse several times without purchasing
    While you don't want to send someone an email every time they visit your website, you might want to send a light touchpoint to those who visit several times in a short period of time but don't engage further. For example, you can trigger a flow to those who have been Active on Site at least 4 times in the last 30 days, but haven't started or completed a checkout.

The _ kx parameter

When you have email to website tracking enabled and have Klaviyo.js on your website, Klaviyo will identify individuals who click through a Klaviyo email and then end up browsing your website. This is one of the main ways Klaviyo is able to identify new site visitors and cookie them so they get identified during all future visits to your page.

The way Klaviyo's email to website tracking works, we add an additional parameter to all URLs in your email. This is the _kx parameter. The unique encrypted value is then decrypted by our Active on Site snippet and allows us to identify the user that clicked through the URL. See the example link below for an idea of how this will look in the URL:

This parameter is automatically appended and should not impact the load times of your links nor break any links based on its placement.

However, if you use URLs that contain query parameters to inform your server to automatically download a file, the _kx parameter could cause your link to break. In order for the download to function properly, either toggle off email to website tracking in your account email settings or configure your server to ignore this parameter. As of now, you can only toggle this off across your account; you cannot turn it off for individual campaigns.

Additional resources

Was this article helpful?
919 out of 1361 found this helpful