URL targeting enables a Feedback widget to show only when a user visits a specific URL provided by you. 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 a Feedback widget based on User Attributes instead of URL, see our article on How To Use User Attributes to Target Surveys and Feedback. For triggering based on Events, see our How to Use Events for Survey and Feedback Targeting guide.
- How to set up URL targeting for Feedback widgets
- Available URL targeting options
- How to exclude pages from your URL targeting settings
How to set up URL targeting for Feedback widgets
In the set up process of your Feedback widget:
Click on the Targeting section.
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 and Feedback Targeting article.
Available URL targeting options
To better understand how URL targeting works, it is good to understand the components that make up a URL. Hotjar evaluates five different URL components when it looks for targeting 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 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 which ends in the entered text.
Target all pages which 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 Feedback widgets section above.
Hotjar can only support the following characters
a-z, A-Z,0-9, -, ., _, /, and ~. Any other characters need to be percent-encoded.
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.
Simple match - https://www.x.com/pages/
The match will be correct if the URL path, query-string and fragment the user is on match EXACTLY the ones you specify.
Exact match - https://www.x.com/pages/?x=1
The match will be correct if the URL the user is on, starts exactly as you specify it, including the protocol.
Starts with - https://www.x.com/pages/
The match will be correct if the URL the user is on, ends exactly as you specify it.
Ends with - pages/
The match will be correct if the URL the user is on, contains the text you specified.
Contains - ?x=1
|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 How to Use Regular Expressions for URL Targeting.
How to exclude pages from your URL targeting settings
Feedback widgets have the option to exclude specific pages from URL targeting criteria. This prevents the widget from appearing on selected pages, even if they match the targeting criteria.
In the settings of your Feedback widget:
Click on the Targeting section.
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 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.