How to Target Visitors Based on Browser Cookies

OptinMonster makes it easy to hide or show campaigns based on the cookies in your visitor’s browser.

In this article, you’ll learn how to use OptinMonster’s Display Rules to hide or show a campaign based on cookies.

Before You Start

Here are some things to know before you begin:

Configure Cookie Rule

When you create a campaign in OptinMonster you can configure it to be shown or hidden based on a visitor’s cookie.

To configure the cookie rule, follow these steps:


  1. Navigate to the Display Rules tab in the campaign builder.
    Display Rules Tab
  2. While editing Display Rules, add a rule and from the dropdown select a cookie to target a user’s cookie.
    Cookie Detection Rule
  3. Next, you’ll see two options appear to set the cookie’s key and value.
    Cookie Rule Settings
    The following options are available for cookie targeting:

    • exactly matches
    • does not exactly match
    • contains
    • does not contain
    • starts with
    • does not start with
    • ends with
    • does not end with
    • is empty
    • is anything
    • matches the pattern
  4. If either the cookie’s key or value is irrelevant, choose the is anything option.
  5. When you’re finished, click Save.


The cookie detection rule allows you to add real-time onsite retargeting campaigns.

For example, if you have an online store, your eCommerce software adds a cookie to every user who has purchased a product from you. When that customer returns to your website, you can use the cookie detection rule to show them a returning customer discount.

The best part is that cookie detection is happening in real-time. Meaning if a user just purchased Product A, you can immediately show them an upsell or special promotion for Product B.

Another use case would be for those who are using an advanced email marketing solution like Infusionsoft, ActiveCampaign, Pardot etc. to run a drip campaign. These solutions add subscriber-specific cookies to your users browser. You can use these to show personalized popups based on the stage the user is inside your marketing funnel.



Cookies are little pieces of data in a web browser that is unique to each site. Each cookie contains only bits of text, nothing else. The text can be a user ID, session ID or any other text.

Cookies are very common, it’s normal to have hundreds or even thousands stored in your browser at any given moment.

For example, cookies help a website determine if you’ve logged into an account and keep you logged in while you continue browsing through the site. Clearing your cookies on that site would immediately log you out of your account.

All cookies have a key and a value: key=value. For example, a cookie could be: country=us

This question is best answered by your web developer, as it depends on your site’s structure, coding language, and your goals.

Here are a few articles to help you learn how to do this effectively:

How do I hide this campaign if the visitor has already seen one of my campaigns?

To hide or show a campaign based on the visitor seeing another specific campaign can be done using MonsterChains.

If you want to hide all campaigns on your site after the visitor has seen or subscribed to any of your campaigns, then you should configure global cookies.