When your visitors load your Hotjar Tracking Code through their browser, Hotjar initiates requests to files which are needed to track usage.
Scripts (.js files)
hotjar-xxxx.js (where xxxx is the site ID)
This file contains and updates changes to the settings of reports and feedback widgets you have set up. Once this file is loaded it requests the modules-xxxx.js, which is described below. This file is only cached for one minute.
modules-xxxx.js (where xxxx is a hash value)
This file contains the code required to track your visitors and will also trigger any feedback widgets you set up on your site, such as Survey invites and Polls. This file accounts for about 99% of the script's file size and changes much less frequently. We cache this for much longer: 365 days or when changed. This reduces needless loading for your visitors
XHR requests and WebSockets
This POST request is what tracks a page visit from a visitor and includes visit information such as the path of the current URL, browser window dimensions, and the visitor’s Hotjar User ID.
XHR: xxxxx (Where xxxxx is a Poll ID)
This request happens whenever a visitor submits a Poll widget response. For every response/answer sent, a new POST request occurs.
This POST request sends the original HTML the visitor loaded for every page visited during their session on the site. This is then used to replay back their session recording.
HTML is not sent to Hotjar if there is already a copy
If the same HTML file already exists on our servers, we will not re-save the HTML file.
This POST request only happens once to a single visitor per Heatmap, per device. It happens for the first visitor to a page after you have set a Heatmap up. The request sends the HTML for the page. This is the HTML used to capture a screenshot of the page used by your Heatmap.
This WebSocket only starts if:
- Recordings are enabled.
- A Heatmap is targeting this page.
- A Form analysis report is targeting this page.
This connection stays open while the visitor navigates and interacts with the website. WebSockets appear as PENDING status: 101 ‘switch protocol’ in the Chrome Dev Tools console. The pending status is what keeps the connection alive while data is being sent.
All XHR requests appear to occur twice
This happens because unlike simple requests these are "pre-flighted" requests. These first send an HTTP OPTIONS request header to the resource on the other domain in order to determine whether the actual request is safe to send. Cross-site requests are pre-flighted like this since they may have implications for user data.