You will learn

Learn how to configure OneTrust cookie management tools, including Auto-Blocking and CookiePro, to work with Klaviyo’s tracking and onsite functionality.

Klaviyo.js is Klaviyo's JavaScript snippet that enables Active on Site tracking and sign-up forms. You have the option to enable this tracking through your ecommerce integration or by pasting the code in your site's theme. When tracking is allowed, Klaviyo.js uses the first-party __kla_id cookie on your website to recognize visitors. This cookie can temporarily hold personally identifiable information. After Klaviyo identifies a visitor (e.g., when they click a tracking link in a Klaviyo-sent email), it stores an encrypted identifier that connects onsite activity with their profile. OneTrust controls whether Klaviyo’s tracking scripts can load based on your cookie consent settings.

Complete the cookie setup steps below in order to configure consent-based tracking while allowing forms that do not require tracking to work.

Prerequisites

We suggest visiting our Guide to Klaviyo Web Tracking for more information on how our cookies capture known visitor information in different ways.

Additionally, it is important that you have already enabled Klaviyo.js, either directly through your ecommerce integration or manually.

Configuring Klaviyo and OneTrust’s tools

Use OneTrust to block Klaviyo’s tracking scripts until visitors give the consent required by your site’s configuration. Blocking all Klaviyo scripts can also stop sign-up forms from working, including forms that do not require tracking.

Klaviyo serves tracking scripts from static-tracking.klaviyo.com and sign-up form scripts from static.klaviyo.com. Configure blocking for the tracking scripts so forms that do not depend on visitor tracking can still load. Klaviyo’s tracking includes:

  • if a visitor is active on site, the site referrer URL
  • if a visitor views a product or adds a product to their cart (if you’ve enabled this separately)

To configure consent-based tracking in OneTrust’s CookiePro tool while allowing forms that do not require tracking to work, follow the steps below.

Add your website to CookiePro

If you haven’t already, you will need to add your website to your CookiePro account.

1. Log into your CookiePro account and click the Cookie Compliance section under My Apps.

View of the CookiePro dashboard with Cookie Compliance section highlighted
View of the CookiePro dashboard with Cookie Compliance section highlighted

2. Click Add Website in the upper right-hand corner.

The Add Website button in the upper right corner of the CookiePro dashboard page
The Add Website button in the upper right corner of the CookiePro dashboard page

3. From here, you will see a section to set up and add your website and scanning details. Fill in your website URL and name of your organization in the first two fields.

Scan Website modal with fields to fill website URL and Organization information
Scan Website modal with fields to fill website URL and Organization information

Note that if you already have an organization associated with your CookiePro account, it will appear in the dropdown as an option.

4. Under the Advanced Options section, you can choose to adjust or add your scanning settings.

5. You can adjust the number of website pages that CookiePro will scan by changing the number in the Limit scan to field. By default, CookiePro will recommend scanning the first 1,000 pages.

Inside Scanning Settings page, the ability to input scanned page numbers in field and toggle option on
Inside Scanning Settings page, the ability to input scanned page numbers in field and toggle option on

6. You can also limit the CookiePro scan to one area of your site. To do this, toggle on the option next to Limit to this path within site. Make sure that your Website URL above reflects this URL path (e.g., retail.com/signups).

Inside the Scanning Settings page, the toggle option to only scan pages within one area of your website
Inside the Scanning Settings page, the toggle option to only scan pages within one area of your website

7. Finally, if there are certain pages or types of pages that you want CookiePro to scan, you can add these in the next few fields. Add page IDs separated by commas to the Scan Pages with Query Parameters field to scan pages by ID number.

You can also scan pages by URL by adding these URLs in the Target Pages to Scan field.

If you have a longer list of URLs or a sitemap, you can copy and paste those into the Sitemap URLs field. These URLs will be scanned first in the scan queue.

In the Scanning Settings page, fields to add additional information on certain pages or areas of your website to scan
In the Scanning Settings page, fields to add additional information on certain pages or areas of your website to scan

8. Once you have all settings completed, click Scan & Configure in the lower right corner.

Configure the static-tracking.klaviyo.com entry

Configure the __kla_id entry that OneTrust associates with static-tracking.klaviyo.com, the source of Klaviyo’s tracking scripts. The __kla_id cookie itself is a first-party cookie stored on your website; these steps configure its entry in OneTrust.

1. Once your website has been added, navigate to Cookiepedia > Categorizations in the left hand navigation.

2. Look for the Klaviyo static-tracking __kla_id cookie either by searching for it in the field above or by scrolling through the list below. It should be the option labeled as “Persistent” with the static-tracking.klaviyo.com hostname.

3. Click the __kla_id cookie option.

Inside the Categorizations page, a highlighted view of the __kla_id cookie in a list
Inside the Categorizations page, a highlighted view of the __kla_id cookie in a list

4. Once on the Cookie Details page, navigate to the Categorization tab.

5. If you have not run a scan with Klaviyo and OneTrust yet, make sure to choose Targeting Cookies from the Select a category dropdown. Make sure that Third-Party Cookie is already populated in the Select a party dropdown.

On the Categorization tab, a modal showing dropdowns for selecting a cookie category and cookie party
On the Categorization tab, a modal showing dropdowns for selecting a cookie category and cookie party

6. Once you have made these updates, click Save in the lower right corner.

7. In this same area, navigate to the Source tab. You should see your website URL appear in the list, as shown in the example below.

Inside the Sources page, a view of your website URL displayed
Inside the Sources page, a view of your website URL displayed

8. Click on your website URL.

9. A dropdown will appear with a new URL; click on the pencil icon to the right.

A highligted view of the pencil editing icon to the right of your website URL
A highligted view of the pencil editing icon to the right of your website URL

10. In the modal, remove your current URL and replace it with: https://static-tracking.klaviyo.com.

11. Click Confirm once you have updated the URL.

A modal view of your Resource URL with a confirm butotn in the lower right
A modal view of your Resource URL with a confirm butotn in the lower right

12. To confirm that the Klaviyo cookie has been updated, navigate to Cookiepedia > Categorizations in the left-hand navigation.

13. Click on the Cookies tab.

14. From here, your __kla_id cookie should show a “1” listed under both the Domain Category Overrides and Domains columns.

On the confirmation screen, a list view showing your __kla_id cookie with domain category overrides and domain as a numeric one
On the confirmation screen, a list view showing your __kla_id cookie with domain category overrides and domain as a numeric one

Configure the static.klaviyo.com entry

Configure the __kla_id entry that OneTrust associates with static.klaviyo.com, which serves Klaviyo’s sign-up form scripts. As with the previous entry, this configures OneTrust’s record of the cookie; it does not collect third-party cookies for Klaviyo.

1. Navigate to Cookiepedia > Categorizations in the left hand navigation.

2. Look for the static.Klaviyo __kla_id cookie either by searching for it in the field above or by scrolling through the list below. It should be the option labeled as “Persistent” with the static.klaviyo.com hostname.

3. Click this __kla_id cookie option.

On the Categorizations page, the __kla_id cookie option highlighted in a list view
On the Categorizations page, the __kla_id cookie option highlighted in a list view

4. Once on the Cookie Details page, navigate to the Categorization tab.

5. Choose Targeting Cookies from the Select a Category dropdown. Make sure that Third-Party Cookie is already populated in the Select a party dropdown.

On the Categorization tab, a modal showing dropdowns for selecting a cookie category and cookie party
On the Categorization tab, a modal showing dropdowns for selecting a cookie category and cookie party

6. Once you have made these updates, click Save in the lower right corner.

7. In this same area, navigate to the Source tab. You should see your website URL appear in the list below.

A modal view of your website URL
A modal view of your website URL

8. Click on your website URL.

9. A dropdown will appear with a new URL; click on the pencil icon that appears to the right of this.

A highligted view of the pencil editing icon to the right of your website URL
A highligted view of the pencil editing icon to the right of your website URL

10. In the modal remove your current URL and replace with: https://static-tracking.klaviyo.com.

11. Click Confirm once you have updated the URL.

A modal of your website URL with a confirm button in the lower right
A modal of your website URL with a confirm button in the lower right

12. To confirm that the Klaviyo cookie has been updated, navigate to Cookiepedia > Categorizations in the left hand navigation.

13. From here, your __kla_id cookie should show a “1” listed under both the Domain Category Overrides and Domains columns.

On the confirmation screen, a list view showing your __kla_id cookie with domain category overrides and domain as a numeric one
On the confirmation screen, a list view showing your __kla_id cookie with domain category overrides and domain as a numeric one

Configuring your website’s first-party cookie

Configure the first-party __kla_id cookie associated with your website to capture events on your ecommerce site.

1. Navigate to Cookiepedia > Categorizations in the left hand navigation.

2. Look for your website specific __kla_id cookie either by searching for it in the field above or by scrolling through the list below. It should be the option labeled as “Persistent” with your website URL as the hostname.

3. Click this __kla_id cookie option.

On the Categorization page, your __kla_id cookie highlighted in a list view
On the Categorization page, your __kla_id cookie highlighted in a list view

4. Once on the Cookie Details page, navigate to the Categorization tab.

5. Choose Targeting Cookies from the Select a Category dropdown. Make sure that First-Party Cookie is already populated in the Select a party dropdown.

On the Categorization tab, a modal showing dropdowns for selecting a cookie category and cookie party
On the Categorization tab, a modal showing dropdowns for selecting a cookie category and cookie party

6. Once you have made these updates, click Save in the lower right corner.

7. In this same area, navigate to the Source tab. You should see your website URL appear in the list below.

A modal view of your website URL
A modal view of your website URL

8. Click on your website URL.

9. A dropdown will appear with a new URL; click on the pencil icon that appears to the right of this.

A highligted view of the pencil editing icon to the right of your website URL
A highligted view of the pencil editing icon to the right of your website URL

10. In the modal remove your current URL and replace with: https://static-tracking.klaviyo.com.

11. Click Confirm once you have updated the URL.

A modal showing your website URL with a Confirm button in the lower right corner
A modal showing your website URL with a Confirm button in the lower right corner

Previewing your updated cookies

1. Navigate to Scripts in the left-hand navigation.

2. On the Scripts page, click on your website URL that appears below.

On the Scripts page, your website URL will appear in the list below to click
On the Scripts page, your website URL will appear in the list below to click

3. Then, click Publish Production in the upper right-hand corner.

View of the Publish Production button to click in the upper right corner of the Scripts page
View of the Publish Production button to click in the upper right corner of the Scripts page

4. In the right sidebar that appears, click Confirm.

5. Once on the Review tab, scroll down and click Continue.

6. Finally, on the Confirm and Publish tab, click Publish Test & Preview. Your preview may take a few seconds to load, but you will see a green check appear below once it’s ready.


7. Once this success message appears, click Confirm below.

Publishing your updated cookies

Before you publish your cookies, it’s important to note that production scripts can take up to 4 hours to take effect on your website. Once you follow the directions below, please wait up to 4 hours to see these updates.

1. Navigate to Websites in the left-hand navigation.

2. On the Websites page, click on your website URL from the list below.

On the Websites page, your website URL will appear in the list below to click
On the Websites page, your website URL will appear in the list below to click

3. From here, click Publish in the upper right corner.

4. A sidebar modal will appear confirming your version to publish. Click Confirm in the lower right corner.

A modal that will appear from the right sidebar to publish your website cookies with confirm button in lower right corner
A modal that will appear from the right sidebar to publish your website cookies with confirm button in lower right corner

5. In this same modal, you will move onto the Review and Publish screen. Click the toggle on Enable Automatic Blocking of Cookies.

You can read more about CookiePro’s Auto-Blocking feature in their guide.

On the Review and Publish screen, a highlighted area to toggle on Automatic Blocking of Cookies
On the Review and Publish screen, a highlighted area to toggle on Automatic Blocking of Cookies

6. Click Publish in the lower right corner.

7. A popup will appear with your Production Scripts. Click Copy Scripts.

A popup window showing your production scripts to copy and paste to your website
A popup window showing your production scripts to copy and paste to your website

8. Place these scripts within the HTML of your ecommerce website. Read more about placing these scripts into your ecommerce website in CookiePro’s step-by-step guide.

Verify your setup

After publishing, test your website in each cookie consent state:

  1. In a fresh browser session, leave Targeting Cookies unaccepted. Check that Klaviyo’s tracking scripts are blocked and that forms which do not require tracking can still display.
  2. Accept Targeting Cookies, then follow the onsite tracking test to confirm that Klaviyo records activity for an identified test visitor.
  3. Withdraw cookie consent and confirm that further onsite activity is no longer tracked.

Additional Resources

  • Understanding cookies in Klaviyo

    Learn more about how Klaviyo uses cookies as a part of our web tracking to gather information and help improve conversion rates and email performance. This article explains the specific cookie we use and its purposes so that you understand how customers are tracked. This information helps you understand how Klaviyo gathers data, and how this may impact customer privacy and compliance laws.

  • Getting started with Klaviyo onsite tracking

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

Was this article helpful?
Use this form only for article feedback. Learn how to contact support.

Explore more from Klaviyo

Community
Connect with peers, partners, and Klaviyo experts to find inspiration, share insights, and get answers to all of your questions.
Partners
Hire a Klaviyo-certified expert to help you with a specific task, or for ongoing marketing management.
Support

Access support through your account.

Email support (free trial and paid accounts) Available 24/7

Chat/virtual assistance
Availability varies by location and plan type