Why would you need JavaScript triggers?

You want a poll to appear only after your visitor has reached a specific part of the page.

You want the survey pop-up to appear as soon as your visitors have abandoned their order.

Note

If a trigger is present on a page, it will cause a widget, a Poll, Survey, Incoming Feedback or Recruiter, to show regardless of any other rules present. Triggers take precedence over other targeting rules.

Using JavaScript triggers

The example below shows you how to use a JavaScript trigger on a poll. You will be able to use the same technique for the other Hotjar features.

Select JavaScript trigger from your page targeting panel.

Enter a name you would like to use as your trigger.

You can select the '+' icon if you would like to add another targeting rule. Only alphanumeric characters, dashes and underscores can be used in the trigger name.

Click Done.

Add the trigger code to your website.

In the example above, you've created a trigger called mypoll. Next, you will need to add the trigger code to your website:

hj('trigger', 'mypoll');

Note

This code must be added at any point after the Hotjar Tracking Code. If it is added before, a JavaScript error will occur.

Trigger for When the User Completed a Specific Action

You would add this line of code to one of your JavaScript functions.

function newsletterSignup() {
...
hj('trigger', 'signup-poll');
}

When using triggers for widgets, your behavior rules will still be followed. As an example, if you set a poll to open after 10 seconds and then use a JavaScript trigger, the poll will appear 10 seconds after triggering it with the code above.