When selecting a URL filter, you can determine how the filter will refine your data by applying a condition such as whether the URL contains, starts with, ends with, etc. This article covers the available condition options when filtering by URL and how they work.
The available URL filtering conditions are:
- Contains / Does not contain
- Starts with / Does not start with
- Ends with / Does not end with
- Is / Is not
- Is exactly
- Matches regex
When reading through this article, it can help to keep the different components of a URL in mind:
Hotjar can only support the following characters
a-z, A-Z,0-9, -, ., _, /, and ~. Any other characters need to be percent-encoded.
Contains / Does not contain
The match will be correct if the URL that users land on includes the text you specified.
Examples
You apply either the Contains or the Does not contain filter condition, entering ?x=1 in the filter condition field. Here's what will or will not be captured by this filter condition.
URL | Matches filter condition? | Reason |
https://www.x.com/pages/?x=1#2 | ✅ | The URL contains the specified text (?x=1). |
https://www.x.com/pages/?x=1&y=1 | ✅ | The URL contains the specified text (?x=1). |
https://www.x.com/pages/subpage | ❌ | The URL does not contain the specified text (?x=1). |
https://www.x.com/pages/ | ❌ | The URL does not contain the specified text (?x=1). |
Starts with / Does not start with
The match will be correct if the URL that users land on starts exactly as you specify it, including the protocol.
Examples
You apply either the Starts with or the Does not start with filter condition, entering https://www.x.com/pages/ in the filter condition field. Here's what will or will not be captured by this filter condition.
URL | Matches filter condition? | Reason |
https://www.x.com/pages/ | ✅ | The start of the URL is a match (https://www.x.com/pages/). |
https://www.x.com/pages/subpage | ✅ | The start of the URL is a match (https://www.x.com/pages/). |
https://www.x.com/pages/?x=1#2 |
✅ | The start of the URL is a match (https://www.x.com/pages/). |
www.x.com/pages/ | ❌ | The URL does not include the protocol (https://). |
Ends with / Does not end with
The match will be correct if the URL that users land on ends exactly as you specify it.
Examples
You apply either the Ends with or the Does not end with filter condition, entering pages in the filter condition field. Here's what will or will not be captured by this filter condition.
URL | Matches filter condition? | Reason |
https://www.x.com/pages | ✅ | The end of the URL is a match (pages). |
https://www.x.com/pages/subpage | ❌ | The end of the URL does not match the specified filter condition (pages). |
https://www.x.com/pages/?x=1#2 |
❌ | The end of the URL does not match the specified filter condition (pages). |
www.x.com/pages | ✅ | The end of the URL is a match (pages). |
Is / Is not
The match will be correct if the URL path that users land on matches the URL path you specify. Query strings, fragments, and the presence or not of 'www' will be ignored.
Examples
You apply either the Is or the Is not filter condition, entering https://www.x.com/pages as the URL in the filter condition field. Here's what will or will not be captured by this filter condition.
URL | Matches filter condition? | Reason |
https://www.x.com/pages/ | ✅ | The domain (x.com) and URL path (/pages) are a match. |
https://www.x.com/pages/subpage | ❌ | /subpage has not been included in the URL path filtering condition applied here, so this will not match the applied filter. |
https://www.x.com/pages/?x=1 | ✅ | The query string (?x=1) is ignored by this filter condition. |
https://www.x.com/PAGES | ✅ | The URL is not case sensitive. |
https://x.com/pages | ✅ | The 'www' is ignored. |
https://www2.x.com/pages | ❌ | Only 'www' is ignored, any other form of prefix or subdomain must be included in the filter condition. |
Is exactly
The match will be correct if the URL path, query string, and fragment that users land on match exactly the ones you specify.
Examples
You apply the Is exactly filter condition, entering https://www.x.com/pages/?x=1 as the URL in the filter condition field. Here's what will or will not be captured by this filter condition.
URL | Matches filter condition? | Reason |
https://www.x.com/pages/?x=1 | ✅ | All URL components are an exact match. |
https://www.x.com/pages/subpage | ❌ | The required query string (?x=1) is missing and the URL path should not include /subpage. |
https://www.x.com/pages/ | ❌ | The required query string (?x=1) is missing. |
https://www.x.com/pages/?x=1&y=1 | ❌ | The URL has a non-matching query string (&y=1) at the end of it. |
https://www.x.com/pages/?x=1#2 | ❌ | The URL has a non-matching URL fragment (#2) at the end of it. |
Matches regex
The match will be correct if the URL matches the pattern specified. This query uses the RE2 flavor of regex.
Examples
In the below examples, the asterisks * indicates a variable part of the URL.
Target | Example REGEX |
www.example.com/pages/*/ |
www\.example\.com\/pages\/(.+) |
www.example.com/pages/*/article | www\.example\.com\/pages\/(.+)\/article |
example.com/products/*, but not example.com/products/*/page or example.com/products/*/otherpage | \/products\/(.+)\/$ |
More examples of regex
For more examples of regex, see our article on How to Use Regular Expressions for Page Targeting and IP Blocking.