URL targeting allows you to start session capture for Session Replay 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 Session Replay 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 Session Replay Targeting guide for triggering replays 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 Replays or Heatmaps based on the URL visited.
How to set up URL targeting for Recordings and Heatmaps
1. Visit your Sites page.
2. Click on the settings cog icon next to the Site to be edited, which will open that Site's settings.
3. From the Site settings page, click on Session targeting & tracking.
4. 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 Replays and Heatmaps based on the URL visited, see the available URL targeting options section below.
- To set up targeting for Replays based on triggering a JavaScript Event, see our How to Use Events for Replay Targeting article. Using Events to trigger Heatmaps is currently not available.
5. 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. Contentsquare evaluates five different URL components when it looks for targeting matches: protocol, domain, path, query strings, and fragments:
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.
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) |