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.
If you're looking to trigger Surveys based on User Attributes instead of URLs, see our article on How To Use User Attributes to Target Surveys. For triggering based on Events, see our How to Use Events for Survey Targeting guide.
- 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
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 How to Set Up Surveys article.
In the setup process of your Survey:
Click on the Targeting section (called Invitation Targeting for Link Surveys).
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.
- To set up targeting based on triggering an Event, see our How to Use Events for Survey Targeting article.
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. -
JavaScript Events
This method targets actions taken by a user to trigger a Survey. JavaScript events override all URL-based targeting, including pages you've excluded from your URL targeting settings. See our article on How to Use Events for Survey Targeting for more details on setting this up.
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.
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. More about REGEX can be found in our guide How to Use Regular Expressions for URL Targeting.
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.
In the settings of your Survey:
Click on the Targeting section (called Invitation Targeting for Link Surveys).
Within the Pages subsection, choose Specific pages.
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.
Scroll to the bottom of the settings and click Save to confirm the changes.