URL targeting enables a Survey to show only when a user visits a specific URL. This article describes how to set up URL targeting, the available targeting options, and options to exclude certain pages from targeting.
Targeting settings can apply to either the Survey itself or to on-site invitations to a Survey. For Popover or Full-Screen Surveys, the targeting settings will determine when your Survey will appear on your site. For Link Surveys, the targeting configurations will determine where an optional Survey invite will appear on your site. Find out more about the types of Surveys in our Types of Surveys article.
- How to set up URL targeting for Surveys
- Available URL targeting options
- How to exclude pages from your URL targeting settings
How to set up URL targeting for Surveys
1. In the setup process of your Survey, click on the Targeting section (called Invitation Targeting for Link Surveys).
2. Within the Pages subsection, choose Specific pages and enter your URL targeting condition.
- To set up targeting based on the URL visited, see the available URL targeting options below.
3. Click Save at the bottom of the setup to confirm the changes.
Available URL targeting options
To better understand how URL targeting works, it is good to understand the components that make up a URL. Five different URL components are evaluated to target matches: protocol, domain, path, query strings, and fragments:
URL components are shown in the image above
Each of the URL targeting criteria can be based on one of the seven match types listed below. Click on a match type to see a set of examples.
-
Simple match
This is the default match type and is used to target a page on your site. This match type ignores any query strings and fragments and the presence or not of 'www'. -
Exact match
Targets a specific URL, including the protocol, which can include a query string and fragment. -
Starts with
Target all pages that have a URL, including the protocol, which starts with the entered text. -
Ends with
Target all pages that have a URL that ends in the entered text. -
Contains
Target all pages that contain the entered text. This rule is case-sensitive. -
Regular Expression
A regular expression, regex or regexp for short, is a unique text string for describing a search pattern.
If you're unsure where to add the targeting rules, take a look at the How to set up URL targeting for Surveys section above.
Note: Only the following characters are supported: a-z, A-Z,0-9, -, ., _, /, and ~. Any other characters need to be percent-encoded.
Simple match
This is the default match type and is intended to be used to target a page on your site. The match will be correct if the URL path the user is on matches the URL path you specify. The protocol, www, query strings, and fragments are ignored if entered in the field.
Example:
Simple match - https://www.x.com/pages/
Exact match
The match will be correct if the URL path, query string, and fragment the user is on match EXACTLY the ones you specify.
Example:
Exact match - https://www.x.com/pages/?x=1
Starts with
The match will be correct if the URL the user is on starts exactly as you specify it, including the protocol.
Example:
Starts with - https://www.x.com/pages/
Ends with
The match will be correct if the URL the user is on ends exactly as you specify it.
Example:
Ends with - pages/
Contains
The match will be correct if the URL the user is on contains the text you specified.
Example:
Contains - ?x=1
Result | Example URL | Why? |
NO MATCH | https://www.x.com/pages/ | The URL does not contain ?x=1 |
NO MATCH | https://www.x.com/pages/subpage | The URL does not contain ?x=1 |
Match | https://www.x.com/pages/?x=1 | The URL does contain the matching criteria (?x=1) |
Match | https://www.x.com/pages/?x=1&y=1 | The URL does contain the matching criteria (?x=1) |
Match | https://www.x.com/pages/?x=1#2 | The URL does contain the matching criteria (?x=1) |
Regular Expressions (REGEX)
The match will be correct if the REGEX you create includes the URL your user visits.
Wildcard examples (where * can be anything)
Example:
Target: www.example.com/pages/*
Example: (http|https):\/\/www.example.com\/pages\/.*
Example:
Target: www.example.com/pages/*/article
Example: (http|https):\/\/www.example.com\/pages\/[^\/]+\/article
Example:
Target: www.example.com/user/<user_id>/profile/(numeric user_id)
Example: (http|https):\/\/www.example.com\/user\/[0-9]+\/profile\/
Wildcard excluding a certain pattern
Example:
Target: All pages which match the pattern but do not include the word "article" or "post" www.example.com/pages/*/subpage
Example: (http|https):\/\/www.example.com\/pages\/(?!article|post)[^\/]+\/subpage
Excluding certain words or patterns in a URL
Example: Target: Pages which include the word "page" and do not include "somepage":
Example: (?=.*page.*)(?!.*somepage).*
Multiple pages that don't follow any pattern
Example: Target these three pages:
- www.example.com/pages/article-one/details/
- www.example.com/pages/some-random-word/details/
- www.example.com/pages/another-post/details/
Example: (http|https):\/\/www.example.com\/pages\/(article-one|some-random-word|another-post)\/details\/
How to exclude pages from your URL targeting settings
Surveys have the option to exclude specific pages from URL targeting criteria. This prevents the survey widget from appearing on selected pages, even if they match the targeting criteria.
Excluding pages from the targeting criteria only applies to URL targeting and not to targeting settings that use JavaScript Events.
1. In the settings of your Survey, click on the Targeting section (called Invitation Targeting for Link Surveys).
2. Within the Pages subsection, choose Specific pages.
3. Under the Exclude the widget on the following URLs heading, click Add rule and enter the URL exclusion condition.
Select the match type relevant to you and enter the URL where you do not want the survey widget to be displayed. More rules can be added by clicking on Add rule again. Also, see the available URL targeting options above for guidance and examples.
4. Scroll to the bottom of the settings and click Save to confirm the changes.