How to Target OptinMonster Campaigns to Visitors Who Viewed a Specific Page

Do you want to show your campaigns only to users who have viewed a certain page on your site? It’s easy to control this with our pages visited rule. Follow this guide to learn how to use the Pages Visited Rule to show campaigns based on page history.

REQUIREMENT: The pages visited rule requires at least a Pro subscription.

What Is the Pages Visited Rule?

The pages visited rules lets you display or hide your campaign based on which page or pages the user has already seen. When the page loads, it checks the URL history for the user, determines whether it matches one of the display rule conditions, and then displays or hides accordingly.

With the pages visited rule, you can:

  • Display a campaign only when a user has seen a specific page, like the checkout page
  • Show a campaign to all users except those who saw a specific page, like a landing page
  • Display a campaign to users who saw some pages but not others, such as show a campaign to someone who saw the checkout page but not the confirmation page

How to Use the Pages Visited Rule

You can set the pages visited rule in the Display Rules tab using the visitor has visited URL path that option.

Page Visited Rule

The following options are available for URL history targeting:

  • exactly matches
  • does not exactly match
  • contains
  • does not contain
  • starts with
  • does not start with
  • ends with
  • does not end with
  • matches the pattern
IMPORTANT: Configuring multiple OR conditions will result in only one condition needing to be true for the campaign to show. Configuring multiple AND conditions will result in all conditions needing to be true for the campaign to show. EXAMPLE: configuring your campaign to load when a page contained the slug blog AND when a page contained the slug keyword will require the visitor’s URL history to contain both the slug blog and the slug keyword to trigger the campaign. Configuring your campaign to load when a page contained the slug blog OR when a page contained the slug keyword will require the visitor’s URL history to contain either the slug blog or the slug keyword to trigger the campaign, but not both. For more information, you can see our ruleset documentation.
How to Properly Use Page Slugs or URL Paths

When configuring the pages visited option, you’ll use page slugs (the URL path) to compare against the user’s page history.

The URL path is a specific portion of a web page’s URL, but not the full URL. Take a look at the following diagram to understand how a URL is constructed.

The structure of a URL

In the following example, the campaign is configured to load only when a page visited exactly matches http://website.com/how-it-works/

Page Visited Exactly Matches

NOTE: The pages visited rule cannot be used to target any part of a URL that comes after a ‘?’ or a “#’ in the URL path, such as ‘website.com/page?key=value’, or ‘website.com/page#heading’ since these are URL parameters and anchor tags, respectively.
Show for Specific Pages

The following rules are positive/inclusionary and can be used to target specific pages in the user’s history:

In the following example, the campaign is configured to load only when a page visited exactly matches http://website.com/how-it-works/

Page Visited Exactly Matches

Hide for Specific Pages

The following rules are negative/exclusionary and can be used to target specific pages you do not want your campaign to show on:

  • does not exactly match
  • does not contain
  • does not start with
  • does not end with

In the following example, the campaign is configured to show for all users except:

  • Those who visited the page ‘How it Works’: https://website.com/how-it-works
  • Those who visited a page where the URL contains the keyword ‘instructions’ such as https://website.com/easy-instructions

Page Visited Does Not Match

IMPORTANT: With the exclusionary rules, you want to put all the conditions within every existing Ruleset and make them an AND conditional. The reason for this is that you want to make sure the previous URLs do not contain or exactly match all of the conditions at the same time.
Show for Some Pages and Hide for Others
NOTE: Before reading this section, we recommend you familiarize yourself with the sections Show for Specific Pages and Hide for Specific Pages first.

For this example, lets say we want to show the campaign to visitors who viewed any blog post except the blog post ‘How it Works’.

In this example, all the blog posts are pages within the blog, so the blog posts ‘How it Works’ and ‘Easy Instructions’ would be ‘https://website.com/blog/how-it-works’ and ‘https://website.com/blog/easy-instructions’ respectively.

To show the campaign to those who viewed any blog post, the easiest way would be to show when a URL in the history starts with ‘blog’. However, we don’t want to show the campaign when they viewed the ‘How it Works’ page, so we set an AND condition for does not exactly match ‘blog/how-it-works’.

Page Visited Start With Does Not Match

Looking to target the user’s current URL? See how to show or hide your campaigns on specific pages