> For the complete documentation index, see [llms.txt](https://docs.shoplift.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shoplift.ai/integrate/analytics-platforms-custom/hotjar.md).

# Hotjar

Track Shoplift test variants in Hotjar to segment heatmaps, recordings, and feedback by A/B test participation.

### Quick Start

Add this code after your Hotjar tracking code:

```javascript
// Hotjar + Shoplift Integration
function initializeShopliftHotjar() {
  if (window.shoplift && window.hj) {
    const visitorData = window.shoplift.getVisitorData();
    
    if (visitorData.visitor && visitorData.visitorTests.length > 0) {
      // Set user attributes
      hj('identify', visitorData.visitor.id, {
        device_type: visitorData.visitor.device,
        country: visitorData.visitor.country
      });
      
      // Tag recordings with test data
      visitorData.visitorTests.forEach(test => {
        hj('event', `shoplift_test_${test.testId}`);
        hj('tagRecording', [`test:${test.testId}`, `variant:${test.hypothesisId}`]);
      });
    }
  } else {
    setTimeout(initializeShopliftHotjar, 100);
  }
}

// Initialize on page load
initializeShopliftHotjar();
```

### Filtering in Hotjar

#### Recordings

Use tags to filter recordings:

* `test:[test_id]` - All users in a specific test
* `variant:[hypothesis_id]` - Users in a specific variant

#### Heatmaps

Create separate heatmaps for each variant to compare user behavior.

#### Events

Filter by `shoplift_test_*` events to analyze specific test participants.

### Best Practices

1. **Create variant-specific heatmaps** for visual comparison
2. **Use consistent tag naming** for easy filtering
3. **Set up saved filters** for frequently analyzed tests
4. **Watch recordings** of both control and variant to identify UX issues


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.shoplift.ai/integrate/analytics-platforms-custom/hotjar.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
