How to track custom events on Hotjar
Track custom events in Hotjar by adding JavaScript event triggers to your website code or using CSS selectors to define specific user interactions. You can then view these events in your Hotjar dashboard under Events or create funnels based on custom event data.
Prerequisites
- Active Hotjar account with tracking code installed
- Basic JavaScript knowledge
- Website administrator access
- Hotjar tracking script properly implemented on your site
Step-by-Step Instructions
Access Events in your Hotjar dashboard
Choose your event tracking method
Configure CSS Selector events
#signup-button or .cta-link). Name your event descriptively like Header CTA Click or Newsletter Signup. Click Verify Selector to test it works correctly.Implement API Events with JavaScript
hj('event', 'event_name');Replace
event_name with your custom event name. Place this code where the event should trigger, such as in a button click handler or form submission function.Add event parameters and conditions
Test your custom event
Create funnels with custom events
Analyze event data and insights
Common Issues & Troubleshooting
Events not showing in dashboard
Check that your CSS selector is correct using browser developer tools. Verify the Hotjar tracking code is properly installed and events may take up to 30 minutes to appear.
API events not triggering
Ensure the hj('event', 'event_name') code is placed after the Hotjar tracking script loads. Check browser console for JavaScript errors that might prevent execution.
Too many false positive events
Refine your CSS selectors to be more specific. Add page URL conditions in Advanced Options to limit where events are tracked.
Events working on some pages but not others
Verify that your CSS selectors exist on all target pages. For API events, ensure the JavaScript code is included on all relevant pages or use a tag manager for consistent deployment.