Google Tag Manager should be installed on your site before you follow this guide
If you don't have Google Tag Manager installed yet you'll need to get that set up first. Use Google's Setup and install Tag Manager article to learn how.
This guide describes how to install the Hotjar Tracking Code using Google Tag Manager (GTM). The three options for this installation are to use the:
- Hotjar and Google Tag Manager integration
- Hotjar Tracking Code tag from within Google Tag Manager
- Custom HTML tag from within Google Tag Manager
You can also use GTM to Send Events to Hotjar and Set User Attributes
After installing Hotjar, you can also use GTM to send Events and User Attributes. Learn more in our articles How to Send User Attributes with Google Tag Manager and How to Send Events to Hotjar with Google Tag Manager
Hotjar and Google Tag Manager integration
Visit your Sites page and click on Install tracking code.
If Hotjar was previously installed on your website, but later removed, you may not see the "Install tracking code" option in. If the "Install tracking code" option is not present, you'll need to follow one of the other installation options mentioned in this article.
Click on Start setup from the Install with Google Tag Manager window.
You'll only see this option if your site has a GTM container installed
You'll be shown the first step for this integration if Hotjar has auto-detected your site has a GTM container. If you do not see the first step, follow the steps on installing the Hotjar Tracking Code tag from within Google Tag Manager.
Select the Google account connected to the GTM container on your site.
This is the site where you will be installing the Hotjar Tracking Code.
Seeing some slightly different screens?
Google controls all of the steps that involve logging into GTM and granting permission to Hotjar. The exact flow and page appearance may change, but the steps should not change much.
Select all the access permissions for Hotjar and click Continue.
Select your GTM account and your GTM tag container, then click Create and Publish Tag.
Make sure you pick the GTM Container that is installed on your site
Hotjar will tell you here if you do not have any containers in this Google account. If you do not, follow the instructions in the official Google documentation.
Click Confirm and Create.
Wait a few minutes for Google to respond, then click Verify Installation.
Follow the Verify Installation prompt.
You should see a message confirming the installation. If you do not, see our How to Check That Hotjar Is Working article. Feel free to contact us if you need any help!
Hotjar Tracking Code tag from within Google Tag Manager
From your Google Tag Manager dashboard, click Add a new tag.
Click the tag icon and select Hotjar Tracking Code from the list.
Enter your Hotjar Site ID into the text field.
To get your Hotjar Site ID, visit your Sites page. From here you will see a listing of the Sites and Organizations you have access to, along with the Site IDs to the left of the Site URL.
Click in the Triggering area to choose what pages the Tracking Code will appear on.
Select All Pages for the trigger and then click Save.
Single Page Applications should only use the "Page View" trigger type
Google Tag Manager's state change triggers conflict with Hotjar's own system for detecting changes in single page applications. For more information, take a look at the Google Tag Manager article about the Page View trigger.
Click the Submit button on the upper right-hand side of the Workspace page.
Click on the Publish button to publish the tag.
Wait a few minutes for Google and then check the installation has worked from within Hotjar.
You should see a message confirming the installation inside Hotjar. If you do not, see our How to Check That Hotjar Is Working article.
Custom HTML tag from within Google Tag Manager
Go to your Sites page and click on the View tracking code link for the Site you want to track.
Click Copy to Clipboard.
From the Google Tag Manager Workspace page, click on the Add a New Tag button.
Click inside the Tag Configuration area.
Select Custom HTML from the list.
Paste the code you previously copied from Hotjar into the text field.
Click inside the Triggering area.
Click All Pages.
This is important - if you choose any other trigger, Hotjar won’t function correctly.
Name the tag and then click the Save button.
Submit your changes.
Make sure your live environment is selected, and click Publish.
Wait a few minutes for Google and then check the installation has worked from within Hotjar.
You should see a message confirming the installation inside Hotjar. If you do not, visit Google Tag Manager Installation Troubleshooting to check your GTM configurations.
If you go through that article and the settings are correct in GTM, visit our How to Check That Hotjar Is Working guide for additional troubleshooting steps.