# Cookie Targeting

Canonical URL: https://support.optimonk.com/en/articles/cookie-targeting

Cookie targeting lets you filter your visitors based on the cookies their browser carries. In the app the rule is called **Cookie segmentation** — *Target by browser cookie values*.

---

## How to set it up

1. Open **Campaigns** in the left menu and click the campaign you want to edit.
2. Open the **Settings** tab of the campaign.
3. Scroll to **Who should see the popup** and click **Add new rule**.
4. Pick **Cookie segmentation** from the list.
5. Fill in the condition:

- **the cookie name** — type it into the first field (`cookie_name`);
- **text** or **number** — what kind of value the cookie holds. This decides which operators you get;
- **the operator** — see below;
- **the value** the cookie has to match.
6. Click **Save** in the modal, then **Save changes** at the bottom of the page.

On a campaign that is already published, the change is pushed to the live campaign — you don't have to publish again for it to take effect.

💡 You can also ask the assistant on the right to set this up for you.

### Operators

With **text** you get: equals · not equals · contains · not contains · is set · is not set.

With **number** you get: equals · greater than · less than · at least · at most · between · is set · is not set. *between* gives you two number fields, a lower and an upper bound.

**is set** and **is not set** check only whether the cookie exists — they need no value.

---

## Several conditions: AND and OR

A cookie rule can hold more than one condition.

- **Add AND condition** adds a row to the current group. Conditions inside a group are **AND**-ed: the campaign shows only when **all** of them match.
- **Add OR group** starts a new group. Groups are **OR**-ed: the campaign shows when **at least one** group matches.

While there is a single group, the block is titled **Conditions**. As soon as you add a second one, the blocks are numbered — **Condition group 1**, **Condition group 2** — and every group after the first carries the note *OR — matches if this group also matches*.

⚠️ A rule can hold at most **10 OR groups**. At the cap the *Add OR group* button is replaced by *Maximum 10 OR groups — remove one to add another.*

If you leave a condition incomplete, the modal tells you when you try to save: *Each cookie condition needs a cookie name.* or *Each cookie condition needs a value.*

---

## Example

Here is a real-life example to help you understand the cookie rule. You can use Google Chrome to check the cookies your website uses.

Visit your website, then press **Ctrl + Shift + i** to open the Developer Tools, and select **Application** from the menu. Under **Storage** you can see the **Cookies** your website uses.

Let's use the landing page cookie for this example. You need the first column (**Name**) for the cookie-name field in OptiMonk, and the second column (**Value**) for the value field.

With this setting the popup will only show up to visitors who arrived on your website on that specific page. The cookie value in this example is

```
%2Fproducts%2Famd-epyc%3Fvariant%3D32372912652332
```

which is generated from the URL the visitor landed on:

```
https://optitest123.myshopify.com/products/amd-epyc?variant=32372912652332
```

As you can see, the cookie stores the landing URL of the visitor, with the special characters encoded: "**/**" becomes "**%2F**", "**-**" stays the same, "**?**" becomes "**%3F**" and "**=**" becomes "**%3D**".

Please note that the type of cookies your website uses depends on your website. If you have a developer, you can ask them what cookies your site sets; if you use a service like Shopify, check their support page or contact their support. We are happy to help too, of course :)

---

## What the rule card shows

Once saved, the rule appears as a card in the **Who should see the popup** section. With one condition it reads *Cookie {name} {operator} {value}*; with several, *{n} cookie conditions*. Click the card to reopen the settings, or use the remove control to delete the rule.

Targeting rules on a campaign are combined with **AND**, and each rule type can be added once — a cookie rule that is already on the campaign is greyed out in the picker with an **Added** tag. Add further conditions inside the existing card instead.
