How to Target Visitors Based on Local Storage

OptinMonster makes it easy to hide or show campaigns based on the Local Storage data 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 Local Storage.

Before You Start

Here are some things to know before you begin:

Configure Local Storage Rule

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

To configure the Local Storage rule, follow these steps:

  1. Navigate to the Display Rules view in the campaign builder.
    Display Rules view in the OptinMonster campaign builder
  2. When adding a new rule, select Local Storage Targeting from the Targeting menu.
    Local Storage display rule in the OptinMonster campaign builder.
  3. Configure the Key and Value operators and fields as you require.
    Local Storage display rule key and value settings in OptinMonster.
  4. The following match options are available:
    • Key only:
      • exactly matches
      • exists
      • does not exist
    • Value:
      • exactly matches
      • does not exactly match
      • contains
      • does not contain
      • starts with
      • does not start with
      • ends with
      • does not end with
      • wildcard
      • is empty
      • is not empty
      • matches the pattern (regex)
  5. When you’re finished, Save the campaign.

Troubleshooting

What is Local Storage?

Local Storage objects are small pieces of data stored in the web browser, similar to cookies or Session Storage objects, are unique to a specific site, and can be accessed by typing `window.localStorage` in a browser console.

Local Storage objects have no expiration date and can only be removed using JavaScript or by clearing the browser’s cache.

All Local Storage objects have a key and a value. For example, a Local Storage object could be eat=pizza

How do I set Local Storage data on my site?

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

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