How to Show or Hide Your Campaigns on Specific Pages

OptinMonster makes it easy to show or hide your campaigns on specific pages using our Display Rules.

In this article, you’ll learn how to show or hide your campaigns on specific pages.

Before You Start

Here are some things to know before you begin:

  • When you see URL path mentioned in this article, the URL path is a specific portion of a web page’s URL, but not the full URL. The URL path is the text after the domain. The structure of a URL
  • This article will cover how to show or hide campaigns on specific pages in the following ways:
    • Display a campaign only on specific pages, like the checkout page
    • Show a campaign on all pages except for some, like all pages except the homepage
    • Display a campaign on some pages and hide on others, such as show a campaign on all blog posts except for a specific post
    • Display different campaigns in different languages using WordPress Multilingual (WPML)
    • Display a campaign when the URL matches a specific pattern using RegEx

Configure Display Rules

When you create a campaign in OptinMonster you may want to show or hide it on specific pages of your site. This is easy to do using OptinMonster’s Display Rules.

To show or hide your campaign on specific pages using the URL path, follow these steps:

  1. In the campaign builder, navigate to the Display Rules view from the top menu.
    display rules for coupon popup
  2. From the Display Rules you can select the current URL path rule to configure how your campaign should be shown or hidden.
    Current URL path
  3. The following options are available for current URL path:
    • is any page
    • is the homepage
    • is not the homepage
    • 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

Examples

Some example configurations are provided below to help get you started:

Display on Specific Pages

The following rules are positive (or inclusionary) and can be used to target specific pages you want your campaign to show on:

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

Page Targeting Exactly Matches

If you want to show the campaign on several specific pages using the inclusionary rules listed above you need to use the OR condition.

OR for Inclusionary Rules

If you add multiple inclusionary conditions with the AND option, you have essentially set the campaign to only show if:

  • the URL path exactly matches Page-1
  • AND the URL path is exactly Page-2
  • AND the website URL path is exactly: Page-3
  • etc.

And all of those at the same time. But it is impossible for a URL to be both: website.com/Page-1 AND website.com/Page-2 at the same time. Instead, you want to show the campaign “IF the URL is exactly this:____” OR “IF the URL is exactly this:____”.

Hide on Specific Pages

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

  • is not the homepage
  • 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 on all pages except:

  • The page ‘How it Works’: https://website.com/how-it-works
  • Pages where the URL path contains the keyword ‘instructions’ like: https://website.com/easy-instructions
  • The homepage: https://website.com

Exclusionary And

Unlike with the inclusionary rules listed above in the Display on Specific Pages section, 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 unlike with the inclusionary rules, when you load a webpage, you want to check that the current URL does not contain or exactly match all of the conditions at the same time.
Display on Some Pages and Hide on Others
Before reading this section, we recommend you familiarize yourself with the first two examples in this section.

In this example, let’s say we want to show the campaign on all blog posts, but not on the blog archive and not on the blog post ‘How it Works’.

The URL for the blog archive is ‘https://website.com/blog’. 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 on all blog posts, the easiest way would be to show the campaign on all pages that starts with ‘blog’. However we don’t want to show it on the blog archive page, so we will want to add an AND condition for does not exactly match ‘blog’. Finally, we don’t want to show the campaign on the ‘How it Works’ page so we set another AND condition for does not exactly match ‘blog/how-it-works’.

Combined Rules

If you have multiple inclusionary AND exclusionary rules, you will still need to use the OR operator for the inclusionary rules. Then, all exclusionary rules can be added as an AND condition.
Display Different Campaigns in Different Languages Using WordPress Multilingual (WPML)
Before reading this section, we recommend you familiarize yourself with the first two examples in this section.

To control which campaigns appear on specific languages of your site when using WordPress and WPML, you can configure the page targeting rules to contain the URL Path for the specific language. For example, the URL Path for English is en, for Romanian it is ro, for Spanish it is es, and so forth. You will usually want to target pages with the starts with rule by following the instructions above in the Display on Specific Pages section.

For example, if you had one campaign in English and one in Spanish, you would set the rule for the Spanish campaign to starts with ‘es’ like this:

Starts with ES

Then, for the English campaign, you can set the rule to starts with ‘en’:

Starts with EN

If you need to include the slash (/) in your URL targeting, such as starts with ‘es/’, you can use the matches the pattern rule instead, see our example below.
Display When the URL Matches a Specific Pattern Using RegEx

You can set a rule to show a campaign only on URLs that match a specific pattern using a Regular Expression, or RegEx for short.

“A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.” – Microsoft

In simpler terms, RegEx looks for characters: be it letters, numbers, or specific symbols to identify a pattern. The results permitted or revoked depend on whether the Input to the Regular Expression Engine matches the pattern being employed by the engine.

This rule is an inclusionary rule and you should look at the Display on Specific Pages section for how to set conditions. Then, you can check out our RegEx pattern matching guide for more information on how to use RegEx and create patterns.

Looking for more ways to target specific pages and visitors on your site? See how to target campaigns based on URL parameters and query arguments!

Troubleshooting

I set my campaign to show on a few specific pages but now it isn’t showing up at all.

Depending on your setup, this will happen if you use multiple inclusionary targeting rules like contains or exactly matches with the AND operator. This is an ‘AND’ in a technical sense.

If you put multiple inclusionary conditions with the AND operator, you have essentially set the campaign to only show if:

  • the URL path exactly matches Page-1
  • AND the URL path is exactly Page-2
  • AND the website URL path is exactly: Page-3
  • etc.

And all of those at the same time. But it is impossible for a URL to be both: website.com/Page-1 AND website.com/Page-2 at the same time.

Instead, you want to show the campaign “IF the URL is exactly this:____” OR “IF the URL is exactly this:____”, which you do by using the OR operator instead.

I set my campaign to not show on a few specific pages but it is still showing on every page.

Depending on your setup, this will happen if you use multiple exclusionary targeting rules like does not contain or does not exactly match with the OR operator. This is an ‘OR’ in a technical sense.

If you put multiple exclusionary conditions with the OR operator, you have essentially set the campaign to only show if:

  • the URL path does not exactly match Page-1
  • OR the URL path does not exactly match Page-2
  • OR the website URL path does not exactly match: Page-3
  • etc.

But none of those at the same time. However, if the site is website.com/Page-1 then it is not website.com/Page-2, so the conditions are true.

Instead, you want to show the campaign “If the URL is not this:____” AND “If the URL is not this:____”, which you do by using the AND operator instead.

When adding a path to the page targeting field, I’m getting a message that says ‘Unnecessary URL components have been removed’

Depending on your setup, the Page Targeting 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.

Instead, you will need to use the specific rules for targeting URL parameters and the rules for targeting anchor tags.