Walkthrough: Using Cookies for audience segmentation

Learn how to segment visitors based on their cookies to personalize for logged-in users, affiliate traffic, on-site actions, and more.

Do you want to personalize for logged-in users? Maybe you identify affiliate traffic using cookies. Or maybe you fire cookies when visitor perform certain actions. In this guide, you will learn how to segment visitors based on existing cookies and how to set up your own cookies to create behavior-based audiences (note: this article is an addition to our main article about behavior-based audiences.).

What are cookies?

A cookie is a small piece of data sent from a website and stored on the user's computer by the web browser. Cookies help your website remember information (e.g. items added to shopping cart, information entered in a form field,...) or record the user's browsing activity (e.g. clicking a button).

Ideas for cookie-based personalization

  • Logged-in users: Existing users need to be retained, not acquired. Change your website messaging accordingly. Inform logged-in users about new and improved features, swap out your salesy content for more in-depth explanations, and change your CTAs to move users further down the funnel.
  • Personalize based on affiliate: You don't use affiliate links, instead you drop cookies to identify who referred a visitor? With cookie-based personalization you can read the cookie-value and personalize your website accordingly. You sell accounting software and you have big affiliate network? Set an "affiliate" cookie and personalize your website by mirroring the affiliate's tone-of-voice and repeat their endorsement. Personalize both, landing page and follow up pages to reassure visitors about the trust the affiliate puts into your business.

xero1 You use affiliate cookies? Create personalizations based on cookie value.

Prerequisite for using cookies

For security and performance reasons, your website doesn't send cookies to Unless by default. So, to create an audience based on a cookie, you need to whitelist the cookie you want to send us in your account settings. Also, bear in mind that the browser cookie can’t be set to httpOnly since we won’t be able to read the cookie or send it to our servers.

Basic: How to use existing cookies

Generally, you have two options - target based on the existence of a cookie or the value of a cookie.

How to personalize based on the existence of a cookie

When setting up your target audience, choose: behavior > cookie > is set > nameofyourcookie


Here, we target users for whom the cookie "isLoggedIn" is set.

How to personalize based on the value of a cookie

If you want to display a variation based on a specific value of a cookie, you'll have to enter both, the name of the cookie and its value → nameofyourcookie=value

cookie2 Here, we target users for whom the cookie "customerPlan" has the value "basic"

Advanced: How to set a new cookie

By adding some custom Javascript, you can set up your own cookies. This way you can personalize based on landing page or pages viewed. Here are the two steps you need to take for this:

Step 1: Add a cookie

Use the advanced editor to add a cookie following this naming structure: Txt.setCookie(name, value, days)

cookie3 xero *In this example we set the cookie Txt.setCookie('solution', 'startup', 365);). *

Step 2: Define the cookie as a targeting condition

Now, use the cookie to define your target audience. Choose: behavior > cookie > is set > nameofyourcookie=value

cookie4 audience

For the "Startup" audience, we use the cookie as a targeting condition. Now, we can personalize for all visitors who initially arrived on the Startup landing page.