How to Show or Hide Your Campaigns on Specific Pages

Do you want to show your campaigns only on specific pages or show your campaigns on all pages except for a select few? Its easy to control this with our Page Targeting Rule.

NOTE: This guide will show you how to effectively use the Display Rule: Visitors browsing specific pages.

What Is the Page Targeting Rule?

The Page Targeting rules lets you display or hide your campaign based on the visitor’s current webpage. When the page loads, it checks the URL of the current page and determines whether it matches one of the display rule conditions and displays or hides itself accordingly.

With the page targeting rule, you can:

  • 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

How to Use the Page Targeting Rule

You will find the Page Targeting rule under the Who should see this campaign? section of the Display Rules.

om page level targeting

The following options are available for URL path targeting:

  • 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
IMPORTANT: Configuring multiple conditions in this section will result in the campaign loading only when all of those conditions are met. EXAMPLE: configuring your campaign to load on pages containing the slug blog and on pages containing the slug keyword will require the visitor’s URL to contain both the slug blog and the slug keyword to trigger the campaign. This is because all rules within a single ruleset are an AND conditional. For more information on this and how to create additional rulesets, you can see our ruleset documentation.
How to Properly Use Page Slugs or URL Paths

When configuring the Visitors browsing one of these pages option, you’ll use page slugs (the URL path) to determine where your campaign should or shouldn’t load on your site.

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 I’m configuring my campaign to load only when the page exactly matches http://website.com/how-it-works/

Page Slug example in the Display Rules panel of the optin builder

NOTE: 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.
Display on Specific Pages

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

In the following example I’m configuring my campaign to load only when the page URL exactly matches http://website.com/how-it-works/

Page Slug example in the Display Rules panel of the optin builder

IMPORTANT: If you want to show the campaign on several specific pages using the inclusionary rules listed above you need to put each rule in its own ruleset. This is because a single ruleset is a set of AND conditions. If you put multiple inclusionary conditions within a single ruleset, you have essentially set the campaign to only load 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 creating separate rulesets for each conditional. Your Default Ruleset can target “Page-1”, Ruleset #2 can target “Page-2”, etc. For more information on this and how to create additional rulesets, you can see our ruleset documentation.

Hide on 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:

  • is not the homepage
  • does not exactly match
  • does not contain
  • does not start with
  • does not end with

In the following example, I have configured my campaign to show on all pages except:

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

display-rules-page-exclusion

IMPORTANT: Unlike with the inclusionary rules listed above in the Display on Specific Pages section, with the exclusionary rules, you do 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
NOTE: Before reading this section, we recommend you familiarize yourself with the sections Display on Specific Pages and Hide on Specific Pages first.

For this example, lets 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’.

In this example, 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 start with ‘blog’. However we don’t want to show it on the blog page, so we will want to add a 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 condition for does not exactly match ‘blog/how-it-works’.

display-rules-include-exclude

IMPORTANT: Combining the notes from the sections Display on Specific Pages and Hide on Specific Pages, if you have multiple inclusionary AND exclusionary rules, you will still need to separate all the inclusionary rules into their own separate Ruleset. Then, all exclusionary rules will need to be added to every Ruleset.
Display Different Campaigns in Different Languages Using WordPress Multilingual (WPML)
NOTE: Before reading this section, we recommend you familiarize yourself with the sections Display on Specific Pages and Hide on Specific Pages first.

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:

display-rules-spanish-pages

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

display-rules-english-pages

NOTE: 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.
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!


Frequently Asked Questions

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

A: Depending on your setup, this will happen if you use multiple inclusionary targeting rules like contains or exactly matches within a single ruleset. This is because a single ruleset is a set of AND conditions. This is an ‘AND’ in a technical sense.

If you put multiple inclusionary conditions within a single ruleset, you have essentially set the campaign to only load 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 creating separate rulesets for each conditional. Your Default Ruleset can target “Page-1”, Ruleset #2 can target “Page-2”, etc.

For more information on this and how to create additional rulesets, you can see our ruleset documentation.

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

A: 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.