A subdomain, such as https://blog.hotjar.com, is a separate domain to your 'root' or 'top level' domain, which would be https://hotjar.com in this example. Hotjar supports cross-domain tracking for subdomains, as long as the same Tracking Code is installed on each of the subdomains you want to track. Keep in mind that visits to any of your tracked domains/subdomains, where the Hotjar Tracking Code is installed, will be counted towards your average daily sessions. There is also a limitation related to Recordings that is listed at the bottom of this article.
Keep in mind the limitations, related to tracking subdomains, which are mentioned later in this article.
Tracking subdomains
To set this up, make sure to install the same Tracking Code from your primary site on all the subdomains you want to track. You can find the JavaScript snippet on the Sites & Organizations page by clicking on the View Tracking Code link next to the site URL.
For help with installing your Tracking Code, check out: How to Install the Hotjar Tracking Code.
This setup will collect data from your domain and subdomains into the same Site Dashboard
This setup will collect data from your primary domain and all subdomains where you have the same Tracking Code installed into the same Site Dashboard. Also, sessions from subdomains will count towards your Observe plan's daily session allowance. With this setup, subdomains do not need to be added as their own sites on your account.
If you want to collect data for different subdomains separately, you can install unique Tracking Codes for each site added to your Organization. Installing individual Tracking Codes for each subdomain will separate data collected from your Site across various dashboards. More information can be found in How to Add Organizations and Sites.
You can toggle between Site Dashboards by clicking on the building icon in the top-left corner of your dashboard.
Only admin-level team members have access to add sites
Only team members with admin access can make changes to the set up of your Hotjar account. A full explanation of our team members permissions can be found in our Team Member Permissions article.
Limitations with Recordings
Cross-domain tracking for top-level domains
Hotjar cannot track across different top-level domains, for example, going from www.example.com to www.site.com.
For Recordings, a unique identifier allows us to track a user's session across multiple pages. However, due to limitations designed to provide a secure browsing experience for the user, we are unable to see this identifier when a user moves to a different top-level domain name.
If this does occur, the current session will end and a new session will be picked up by Hotjar, causing the Recording session to end.
Cross-domain tracking while starting Recordings on a specific page
We have a limitation when setting Recordings to start on a specific page when recording cross-domain.
When you set Recordings to start on a specific page, we set a session cookie for the user telling our script to record all subsequent pages. Since session cookies are bound to each domain/subdomain, we're not able to read the cookie if the domain/subdomain changes. This causes the active Hotjar session to stop when the user goes to a new domain or subdomain.
The current workarounds we have for this are:
- Remove the page targeting and instead record all pages on your site.
- Add additional domains/subdomains to the page targeting (as outlined in the example section below).
Example of tracking across a domain and subdomain
To prevent a session from being split when the user moves from one domain to another, you can update your targeting settings to include all domains/subdomains that might be visited in the same user session.
For example, let's pretend we have an eCommerce store with a cart page on the following primary domain: https://www.example.com/cart/ and during the checkout process, users are redirected to a subdomain like this: https://checkout.example.com/
To ensure the session is tracked across the domain and subdomain, we would need to alter the Recordings targeting rules to include both domain targets. It would look something like this:
Simple: https://www.example.com/cart/
OR
Starting with: https://checkout.example.com/
Below is a screenshot to illustrate what this would look like in your targeting settings:
For more help with page targeting, visit Configuring Site Settings.