Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

How to Use Cookie Retargeting in WordPress to Show Custom On-Site Messages

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Do you want to use cookie retargeting in WordPress?

Cookie retargeting is the secret tool already used by many of the most popular websites. It allows you to show custom on-site messages to your users based on their past behavior which helps you boost sales.

In this article, we’ll show you how to use cookie retargeting in WordPress to show custom on-site messages and boost conversions.

How to use onsite cookie retargeting in WordPress

What is Cookie Retargeting?

Cookie retargeting is a marketing technique where websites use cookies to track user behavior and offer a personalized experience.

There are two types of cookie retargeting techniques.

First, there is off-site cookie retargeting. This method is used to track user activities across the web.

Facebook pixel and Google remarketing are two of the most popular advertising programs that allow you to use their massive reach and show targeted ads to people who visit your website.

Secondly, you have on-site cookie retargeting, which allows you to show targeted messages to users based on how they interact with your WordPress website.

What are cookies?

Cookies are small text files containing pieces of data. Websites set cookies in users’ browsers to store temporary information such as login status, user preferences, session details, and more.

If you’ve landed a specific product page, only to be retargeted with ads for that exact product while browsing on other websites, you know how powerful cookie retargeting is.

How to Use On-Site Cookie Retargeting to Boost Conversions?

There are a number of ways website owners use on-site retargeting messages to boost conversions and increase sales.

Cookies are mainly used to track users’ behavior and then serve targeted content based on their past interactions.

For instance, eCommerce stores can show custom offers to users based on how they interact with other offers. This allows you to create a dynamic sales funnel that leads users to make a purchase.

Another use-case scenario would be lead generation. With on-site retargeting, if a user closes one sign-up form, then you can show them a different message with another offer.

On-site retargeting messages are highly effective because:

  • It shows personalized messages to users at a time when they are already engaged with your website.
  • Allows you to create customized campaigns that get better with each user interaction until they convert
  • You save money on paid advertising campaigns by utilizing your existing website traffic to the max.
  • You can extend the reach of your retargeting by using ads on other platforms.

The idea is to keep your brand top-of-mind and gently nudge your audience down the funnel. For example, when website visitors leave without converting, you could offer them a limited-time discount to help sweeten the deal and remind them what they’re missing out on.

That being said, let’s take a look at how to use cookie retargeting in WordPress.

Creating On-Site Retargeting Campaign in WordPress

The best way to create on-site retargeting messages is by using OptinMonster. It is the best conversion optimization and lead generation software in the world.

You can use it to easily create attention-grabbing signup forms, popups, welcome mats, in-line offers, custom offers, and more.

For more details, see our complete OptinMonster review.

First, you need to sign up for an OptinMonster account by visiting the website and clicking the ‘Get OptinMonster Now’ button. You’ll need at least their Pro plan for cookie retargeting and Growth plan for follow-up campaigns.


Next, you’ll need to install and activate the OptinMonster plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

This plugin acts as a connector between your WordPress site and the OptinMonster app.

Upon activation, you will see the welcome screen. Simply click the ‘Connect Your Existing Account’ button.

Connect your existing account

Next, a new window will open, where you’ll need to sign in to your account and connect your website with OptinMonster.

Go ahead and click the ‘Connect to WordPress’ button.

Connect OptinMonster to WordPress

Now, you’re ready to create a new campaign.

First, you’ll need to go to OptinMonster » Campaigns from your WordPress admin panel and then click the ‘Create Your First Campaign’ button.

Create first OptinMonster campaign

This will take you to the OptinMonster website, where you’ll be asked to choose a campaign type and a template.

You can choose any campaign type or template, but for this tutorial, we’ll be creating a lightbox popup.

Choose a campaign type and template

You can select any template that you’d like to use for your campaign.

Next, you’ll be asked to provide a name for your campaign and click the ‘Start Building’ button.

Click start building

After that, you’ll enter the drag-and-drop campaign builder interface.

It is a powerful design tool where you can simply point and click on any item to edit it. You can also add new items like buttons, images, columns, and more to your popup campaign.

Edit your onsite targeting campaign

Next, you can switch to the ‘Display Rules’ tab at the top.

Here, OptinMonster will give you different options for displaying your onsite targeting campaigns.

Select display rules

For instance, you can show the popup after users spend a certain amount of time on the page, are from a particular location, or are about to exit your website.

By default, OptinMonster will show your campaign after a visitor spends at least 5 seconds on the site. Plus, it appears on all the pages.

Set up display rules

Once you are satisfied, simply switch to the Publish tab.

Next, you’ll need to make your campaign live by changing its status from Draft to Publish. Don’t forget to click the ‘Save’ button when you’re done.

Publish your onsite targeting campaign

Now by default, OptinMonster will show this campaign to all users who visit your website. Users will be able to close the popup or perform their desired action.

Creating a Retargeting Campaign to Show Custom Messages

Now that you have launched your first campaign let’s add another campaign using the follow-up retargeting feature.

Click on the Create New Campaign button in the OptinMonster dashboard and select your campaign type and template. Since we have used a lightbox popup, we’ll be using a ‘Floating bar’ as our retargeting campaign.

Choose a floating bar template

After selecting a template, you’ll enter your campaign name.

Then, simply click the ‘Start Building’ button to continue.

Click start building

After that, you’ll enter the OptinMonster builder, where you can design your campaign using simple drag-and-drop tools.

You can edit the optin text, adjust the countdown timer to generate FOMO, add a coupon, and so much more.

Edit the floating bar campaign

Once you are satisfied with the design, it is time to select which users you want to show this custom message to.

Simply switch to the Display Rules tab at the top of the builder. OptinMonster offers a ton of display rules from which you can choose. You can also add multiple rulesets.

Choose has closed display rule

Next, under the If menu, go to the ‘Personalization’ display rules options and select Has Closed.

After that, select ‘Campaign’ and then select your previous campaign.

Select previous campaign

Next, you need to switch to the ‘Publish’ tab.

Here, simply change your campaign status from Draft to Publish under ‘Publish Status.’ Once that’s done, simply click the ‘Save’ button and exit the campaign builder.

Publish has closed campaign

You can now visit your website in the incognito browser tab to see your campaign and the follow-up retargeting message.

Adding Cookie Retargeting with Custom Messages

Cookie retargeting allows you to show custom messages to users based on their previous actions, cart status, shopping history, and more.

This allows you to create promotions and upsells designed for customers at different stages of your sales funnel.

When customizing your campaign, simply switch to the ‘Display Rules’ tab.

Under the If menu, you can go to the ‘Targeting (Who)’ display rules options and select Cookie Targeting.

Select cookie targeting

Next, you’ll need to enter the cookie key and value. The key is the cookie name, and the value parameter is the contents of the cookie.

OptinMonster lets you select different operators to use for the display rule. These include options like match exactly, contain, exist, start with, ends with, and more operators.

For instance, if you are using WooCommerce, then you can use WooCommerce cookies to target users who have added products to their cart. This way, you can cross-sell items in their cart, reduce cart abandonment, and more.

Enter cookie key and value

After adding cookie retargeting rules, go to the ‘Publish’ tab.

From here, simply change the Publish Status from Draft to Publish for your campaign.

Publish has closed campaign

OptinMonster will now display your custom message based on the cookie-targeting rules you have set.

Optimizing Your Retargeting Campaigns with A/B Tests

Don’t make the mistake of just letting your retargeting campaigns run on auto-pilot without checking how they’re performing.

Like any marketing campaign, you need to always run A/B split tests so that you know which ones are most effective.

You should be tweaking the headlines, copy, offer, or even the target segmentation in your campaigns to boost conversion rates. The good news is that OptinMonster makes setting up various versions of your retargeting messages super easy.

All you need to do is hit the ‘Create Split Test’ icon located in your account dashboard.

create split test

A pop-up window will appear. Include any notes so you know which elements of the campaign are being tested.

Click the ‘Create Split Test’ button.

split test

This automatically duplicates your campaign along with the cookie retargeting rules that you’ve set forth. That way, you can make the small tweaks needed to analyze your test.

Then, when published, each version of that campaign randomly appears in your website’s traffic to inform you which is performing better.

Over time, you’ll know what your visitors respond best to, thereby boosting your conversion rates by coming A/B testing with your cookie retargeting campaigns.

We hope this article helped you learn how to use cookie retargeting in WordPress to show custom on-site messages. You may also want to see our guide on how to add a cookies popup in WordPress for GDPR, as well as our proven tips on how to increase your landing page conversions by 300%.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

1 CommentLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.