Hotjar
@picked/hotjar sends the events of the Picked client to Hotjar. Each event becomes a
Hotjar event, and the Picked ID of the visitor identifies the Hotjar user.
import { createClient } from 'picked'
import { hotjarPlugin } from '@picked/hotjar'
const client = createClient({
projectId: 'your-project-id',
plugins: [hotjarPlugin({ siteId: 1234567 })],
})Options
| Option | Type | Default | Description |
|---|---|---|---|
siteId | number | required | The ID of your Hotjar site. |
snippetVersion | number | 6 | The version of the Hotjar script. |
trackedEvents | string[] | See Events | The client events that the plugin sends to Hotjar. |
getUserAttributes | () => Record<string, string | number | boolean> | none | Gives more attributes for the Hotjar user. |
autoStartRecording | boolean | true | Sends recordingStartEvent on the first experience_initialize event. |
recordingStartEvent | string | 'hotjar_start' | The name of the Hotjar event that starts a recording. |
Events
The default value of trackedEvents is:
step_enterstep_completestep_submitfield_validation_errorexperience_completeexperience_initializesession
The plugin starts Hotjar on the first tracked event. The name of each Hotjar event is the
event type, the experience name, and the step name, joined by >. An example is
step_enter > Quiz > Question 1. An event without an experience has only its type.
The plugin keeps each event until Hotjar is ready, and then sends the events in order.
User attributes
On the session event, the plugin calls Hotjar.identify with the Picked ID of the
visitor. The attributes are projectId and the return value of getUserAttributes.
The plugin does nothing outside a browser.
