Events for Surveys and Feedback is only available on the Ask Plus, Ask Business, and Ask Scale plans.
Events for Surveys and Feedback can only be used on our paid Ask plans. If you're interested in upgrading, see our article on How to Upgrade Your Hotjar Plan.
Using Events for Feedback widget targeting can be useful when Hotjar's URL targeting rules are not enough to target a specific audience. Keep in mind that Event-based targeting overrides all URL-based targeting, including Excluded URL targets.
Events could also be used if:
- You want a Survey to appear, only after a user has reached a specific part of the page.
- You want the Survey to appear as soon as a user clicks on a specific element.
This feature is also available for Recordings.
Looking to trigger Surveys or Feedback widgets based on the URL visited?
See our How to trigger Surveys or Feedback based on URLs guide for more details. If you're wanting to trigger Surveys or Feedback based on JavaScript Events, see the steps below.
Step By Step Guide
Select Event from your page targeting panel.
Enter a name you would like to use as your event.
You can select the '+' icon if you would like to add another targeting rule. Only alphanumeric characters (a-z, A-Z, 0-9), underscores (_), and dashes (-) can be used in the event name.
Enter any additional targets you'd like for the Feedback widget.
Events will show before other targeting rules
If a targeted Event is present on a page, it will cause the Survey or Feedback widget to show regardless of any other rules present.
Click Done.
Add the event code to your website.
In the example above, we've created an event called viewed_test_variant_a. Next, you will need to add the event code to your website:
hj('event', 'viewed_test_variant_a');
NOTE: The Hotjar event code should run after the Hotjar script is loaded
If there's a chance that your event would fire on the page before your Hotjar Tracking Code, you would need to add this line of code right before your event code:
window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};
Advanced Event Settings
This code is for advanced Hotjar users who have experience with Javascript
If you'd like to implement any of this code, we'd suggest reaching out to your web development team to make sure installation is correct.
Events for When the User Completed a Specific Action
In this scenario, you would add this line of code to one of your JavaScript functions:
function newsletterSignup() { ... hj('event', 'clicked-newsletter-signup'); }
When using events for Surveys, your behavior rules will still be followed. As an example, if you set a survey to open after 10 seconds and then use an event for targeting, the Survey will appear 10 seconds after the code above has been triggered (not based on when the page loaded).
Trigger on page events, not state changes.
Hotjar Events were designed to allow Surveys and Feedback widgets to appear based on 'events' that occur on a webpage. Targeting Hotjar events based on 'state changes' rather than 'events' on the page can cause inconsistent performance and is not advised.
The Hotjar event code should run after the Hotjar script is loaded
If there's a chance that your event would fire on the page before your Hotjar Tracking Code, you would need to add this line of code right before your event code:
window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};
You can also set up Events through Google Tag Manager.
If you use Google Tag Manager to load the Hotjar script on your site, you can set up Hotjar events on the GTM tag that fires the Hotjar tracking code. Check out this guide to help you set up Hotjar events in GTM.