Understanding URL targeting
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:
- Simple match: This is the default match type and is used to target a page on your site, ignoring any query strings and fragments as well as protocol, http vs https, 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;
- Contains: 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.
- JavaScript: Available only on our Plus and Business plans, this method targets actions taken by a visitor to trigger a Heatmap screenshot. JavaScript triggers override all URL based targeting, including Excluding URLs.
If you are unsure where to add the page targeting rules, take a look at Where can I set up my URL targets? more info.
Hotjar can only support the following characters
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 your visitor 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 - http://www.x.com/pages/
Result | Example URL | Why? |
MATCH | http://www.x.com/pages/ | The domain (x.com) and page path (/pages) is a match |
NO MATCH | http://www.x.com/pages/subpage | /subpage is not part of the page path criteria |
MATCH | http://www.x.com/pages/?x=1 | The query string (?x=1) is ignored |
MATCH | http://www.x.com/pages/?x=1&y=1 | The query string (?x=1&y=1) is ignored |
MATCH | http://www.x.com/PAGES | The Simple Match method is NOT case sensitive |
MATCH | https://www.x.com/pages/ | The HTTPS protocol is ignored |
MATCH | http://x.com/pages | The www. prefix to the domain is ignored |
MATCH | https://x.com/pages/ | The HTTPS and www. prefix to the domain are ignored |
Exact match
The match will be correct if the URL path, query-string and fragment your visitor is on match EXACTLY the ones you specify.
Example:
Exact match - http://www.x.com/pages/?x=1
Result | Example URL | Why? |
NO MATCH | http://www.x.com/pages/ | The required query string (?x=1) is missing |
NO MATCH | http://www.x.com/pages/subpage | The required query string (?x=1) is missing and the page path should not include /subpage |
MATCH | http://www.x.com/pages/?x=1 | All URL components are an exact match |
NO MATCH | http://www.x.com/pages/?x=1&y=1 | The URL has a non-matching query string (&y=1) at the end of it |
NO MATCH | http://www.x.com/pages/?x=1#2 | The URL has a non-matching URL fragment (#2) at the end of it |
NO MATCH | https://www.x.com/pages/?x=1 | The URL protocol (HTTPS) needs to be changed to HTTP to become an exact match. |
Starts with
The match will be correct if the URL your visitor is on, starts exactly as you specify it, including the protocol.
Example:
Starts with - http://www.x.com/pages/
Result | Example URL | Why? |
MATCH | http://www.x.com/pages/ | The entire URL matches the target criteria |
MATCH | http://www.x.com/pages/subpage | The URL starts with the matching URL, so it's still a match, even though the end includes /subpage |
MATCH | http://www.x.com/pages/?x=1 | The URL starts with the target criteria, so it's still a match, even though the end includes the ?x=1 query string |
MATCH | http://www.x.com/pages/?x=1&y=1 | The URL starts with the target criteria, so it's still a match, even though the end includes the ?x=1&y=1 query string |
MATCH | http://www.x.com/pages/?x=1#2 | The URL starts with the target criteria, so it's still a match, even though the end includes the ?x=1 query string and #2 fragment |
NO MATCH | https://www.x.com/pages/ | The URL protocol (HTTPS) does not match the criteria. It would need to be changed to HTTP to become a match |
NO MATCH | http://x.com/pages/ | Part of the domain (www.) is not included and therefore does not match the criteria |
Ends with
The match will be correct if the URL your visitor is on, ends exactly as you specify it.
Example:
Ends with - pages/
Result | Example URL | Why? |
MATCH | http://www.x.com/pages/ | The URL ends with the matching criteria (pages/) |
MATCH | https://www.x.com/folder/pages/ | The URL ends with the matching criteria (pages/) |
NO MATCH | http://www.x.com/pages/subpage | The URL path does not end with pages/ |
NO MATCH | http://www.x.com/pages/?x=1 | The URL ends in a query string (?x=1) and not the path pages/ |
NO MATCH | http://www.x.com/pages/?x=1&y=1 | The URL ends in a query string (?x=1) and not the path pages/ |
NO MATCH | http://www.x.com/pages/?x=1#2 | The URL ends in a fragment (#2) and not the path pages/ |
MATCH | https://www.x.com/folder/pages/ | The URL ends with the matching criteria (pages/) |
Contains
The match will be correct if the URL your visitor is on, contains the text you specified.
Example:
Contains - ?x=1
Result | Example URL | Why? |
NO MATCH | http://www.x.com/pages/ | The URL does not contain ?x=1 |
NO MATCH | http://www.x.com/pages/subpage | The URL does not contain ?x=1 |
MATCH | http://www.x.com/pages/?x=1 | The URL does contain the matching criteria (?x=1) |
MATCH | http://www.x.com/pages/?x=1&y=1 | The URL does contain the matching criteria (?x=1) |
MATCH | http://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 Page Targeting.
Where can I set up my URL targets?
Page targeting options can be found for Incoming Feedback widgets and Surveys when you select On pages I specify. Otherwise, these tools will target all pages that have your unique Hotjar Tracking Code installed on them.
Incoming Feedback configurations
If you create a new Incoming Feedback widget, or if you edit an existing one, you'll see a section like this:
Survey targeting configurations
If you want your Survey questions to appear on your website as a widget, you'll need to ensure that the Location is set to On-site.
For External Link Surveys, the targeting configurations determine where an optional "Survey invite" will appear, which prompts your users to visit your External Link Survey page, separate from your website.
Click the button for On pages I specify to add specific URL targets for your On-site Survey or External Link Survey invite.