Recently I had to run a Hotjar poll after a successful signup uncovering hooks. We wanted to ask users what persuaded them to sign up. But our registration is not happening on a dedicated thank-you page – there’s a GTM data layer event which is loaded when a signup happens.
For Plus and Business accounts (paid) Hotjar offers an option in poll settings called JavaScript Triggers. So that’s what we’ll use here. Let’s build a new poll by going to Polls – New and give it a name.
On the Targeting step we’ll click On pages I specify and select the last option (unfortunately it will be active in paid plans only)
We’ll call the Hotjar event ‘success’, so that’s what I’ll enter here:
Finish the rest of the poll setup: Question, Appearance and Behavior, and let’s head to Google Tag Manager to add the special JavaScript trigger that will show the poll on the specific event we want.
Start by creating a new Custom HTML tag in GTM. Give it a name and paste the following in the HTML box:
<script>
hj(‘trigger’, ‘success’);
</script>
It comes from the Hotjar documentation on JavaScript triggers.
Here’s our tag, where I’ve selected an existing datalayer event for trrigger:
That’s it – just save and publish the tag in GTM and enable your poll in Hotjar!