Plan availability
Observe , Observe , or Observe Observe or Observe
URL targeting allows you to start session capture for Recordings and Heatmaps when a user visits a specific URL. This article describes how to set up URL targeting, the available targeting options, and offers examples of URLs that would and wouldn’t match each of these options.
Targeting session capture for Recordings and Heatmaps will not affect where Surveys appear. They will continue to work based on the specific settings for each survey.
If you're looking to use JavaScript Events for triggering, see our How to Use Events for Recordings Targeting guide for triggering Recordings using Events. It's not currently possible to trigger Heatmaps based on Events. However, you can filter collected Heatmap data based on Events using Heatmap filters.
See the steps below for details on triggering Recordings or Heatmaps based on the URL visited.
How to set up URL targeting for Recordings and Heatmaps
Admin-level permissions are required to configure session capture settings for URL targeting.
You'll need to have Admin permission levels to make the changes to your session capture setup described in this section. You can check which team members have the required Admin permission level by visiting your Team page.
Visit your Sites page.
Click on the settings cog icon next to the Site to be edited, which will open that Site's settings.
From the Site settings page, click on Session targeting & tracking.
Select Start capturing sessions on specific pages or when a custom event fires and enter your match criteria.
A dropdown menu appears, allowing you to choose a match type option alongside a text field to enter your match criteria.
- To set up targeting for Recordings and Heatmaps based on the URL visited, see the available URL targeting options section below.
- To set up targeting for Recordings based on triggering a JavaScript Event, see our How to Use Events for Recordings Targeting article. Using Events to trigger Heatmaps is currently not available.
Triggering Heatmaps based on Events is not currently available.
The functionality to trigger Heatmaps based on JavaScript Events is not currently available. However, you can still trigger Heatmaps based on URL and also filter your collected Heatmap data based on Events. Learn more about filtering for Events in our Heatmap filters article.
After entering the match type and match criteria, click Save Changes.
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 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 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. -
Event
This method targets actions taken by a user to trigger session capture. JavaScript Events override all URL-based targeting. See our article on How to Use Events for Recordings Targeting for 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 Recordings and Heatmaps section above.
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 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 How to Use Regular Expressions for URL Targeting.