Skip to content
LogoLogo

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

OptionTypeDefaultDescription
siteIdnumberrequiredThe ID of your Hotjar site.
snippetVersionnumber6The version of the Hotjar script.
trackedEventsstring[]See EventsThe client events that the plugin sends to Hotjar.
getUserAttributes() => Record<string, string | number | boolean>noneGives more attributes for the Hotjar user.
autoStartRecordingbooleantrueSends recordingStartEvent on the first experience_initialize event.
recordingStartEventstring'hotjar_start'The name of the Hotjar event that starts a recording.

Events

The default value of trackedEvents is:

  • step_enter
  • step_complete
  • step_submit
  • field_validation_error
  • experience_complete
  • experience_initialize
  • session

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.