How to Target Visitors With a Specific Anchor Tag

Do you want to show your campaigns only to visitors with a specific anchor tag? Its easy to control this with our Page Targeting Rule. Use the guide below to set up the anchor tag display rule for your campaigns.

NOTE: This guide will show you how to effectively use the Display Rule: Visitors with a specific URL anchor tag.
Requirement: The Anchor Tag rule is only available for those with a Pro Subscription or higher.

What Is the Anchor Rule?

The anchor tag rules lets you display or hide your campaign based on URL anchor tags, which is the part of the URL that follows a ‘#’ symbol. Anchor tags can be used to link a visitor to a specific part of your webpage, like a heading in the middle of the page. For example, in the URL ‘https://www.domain.com/page#heading’ the anchor tag is ‘heading’.

When the page loads, the anchor tag rule checks the URL of the current page and determines whether it matches the display rule conditions and displays or hides itself accordingly.

With the anchor tag rule, you can:

  • Display a campaign when the URL contains a specific anchor tag
  • Always show a campaign except when the URL contains a specific anchor tag
  • Display a campaign when the URL contains an anchor tag that matches a specific pattern using RegEx

How to Use the Anchor Tag Rule

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

display-rules-anchor-tag

The following options are available for Anchor Tag targeting:

  • exactly matches
  • does not exactly match
  • contains
  • does not contain
  • starts with
  • does not start with
  • ends with
  • does not end with
  • is empty
  • is anything
  • 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 anchor tag blog and on pages containing the anchor tag keyword will require the visitor’s URL to contain both the anchor tag blog and the anchor tag 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.
Show to Users With a Specific Anchor Tag

The following rules are positive / inclusionary and can be used to target anchor tags you want your campaign to for:

In the following example I’m configuring my campaign to load only when the page URL contains the anchor tag ‘heading’ like in ‘http://website.com#heading/’ or ‘http://website.com/page#heading’.

display-rules-anchor-tag-example

IMPORTANT: If you want to show the campaign for several specific anchor tags 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 anchor tag exactly matches tag-1
  • AND the URL anchor tag is exactly tag-2
  • AND the website URL anchor tag is exactly: tag-3
  • etc.

And all of those at the same time. But it is impossible for a URL to be both: website.com#tag-1 AND website.com#tag-2 at the same time. Instead, you want to show the campaign “IF the URL anchor tag is exactly this:____” OR “IF the URL anchor tag is exactly this:____”, which you do by creating separate rulesets for each conditional. Your Default Ruleset can target “tag-1”, Ruleset #2 can target “tag-2”, etc. For more information on this and how to create additional rulesets, you can see our ruleset documentation.

Hide From Users With a Specific Anchor Tag

The following rules are negative / exclusionary and can be used to target anchor tags you do not want your campaign to show for:

  • 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 for all URLs except:

  • When the anchor tag contains ‘heading’, like: https://website.com/how-it-works#heading
  • When the anchor tag contains the keyword ‘instructions’ like: https://website.com#easy-instructions

display-rules-anchor-tag-example-exclusionary

IMPORTANT: Unlike with the inclusionary rules listed above in the Show to Users With a Specific Anchor Tag 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 When the Anchor Tag Matches a Specific Pattern Using RegEx

You can set a rule to show a campaign only on URLs with anchor tags 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 Show to Users With a Specific Anchor Tag 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!