If you don't have Google Tag Manager installed yet you can find out how in the Google Tag Manager support article about installing it.
This guide outlines how to add Hotjar via the official Google Tag Manager integration which is suitable for many common Hotjar setups, but it can also be added manually as a Custom HTML tag.
Hotjar - GTM integration
As soon as you have created the Site in Hotjar, you will be presented with the first step if Hotjar has auto-detected your site has a GTM container. If you do not see the first step, choose the GTM installation.
Open your dashboard and click on Install Hotjar.
Click on Start setup within the Install with Google Tag Manager box.
Select the Google account with the GTM container you want to publish Hotjar into.
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.
Allow and confirm permissions granted by clicking Allow.
Select your GTM Account and Tag Container.
Click Create And Publish Tag.
Make sure you pick the Container that is installed on your site!
Hotjar will tell you here if you do not have any containers in this account. If you do not, follow the instructions in the official Google documentation.
Click Confirm and Create.
Wait a few minutes, then click Verify Installation
Follow the Verify Installation prompt.
As soon as you have created the Site in Hotjar, you will be presented with the first step if Hotjar has auto-detected your site has a GTM container. If you do not see the first step, use the following method of installation from inside Google Tag Manager.
Click Add a new tag.
Click the tag icon & select Hotjar Tracking Code from the list.
Enter your Hotjar Site ID into the text field.
To get your Hotjar Site ID, look at the URL of your browser while you're logged into Hotjar: http://insights.hotjar.com/sites/**[SITE_ID]**/dashboard.
You can also navigate to your Sites & Organizations list from the Settings menu. From here you will see a listing of the Sites and Organizations you have access to, along with their IDs.
Set up a trigger to control Hotjar.
Once you click in the Triggering area, you can choose what pages the Tracking Code will appear on.
Select All Pages for the trigger.
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.
Save your workspace.
Click the Submit button on the upper right-hand side of the page.
Click on the Publish button to publish the tag.
Keep the Tracking Code in mind when making design changes
Custom HTML installation
In addition to installing Hotjar by using the handy “Hotjar Tracking Code” tag type, you can install our Tracking Code on GTM as a Custom HTML tag.
Go to your Sites list and click on the View tracking code button for the Site you want to track.
Click Copy to Clipboard.
In Google Tag Manager, click on the Add a New Tag button.
Click where it says Choose a tag type to begin setup…
Select Custom HTML from the list.
Paste the code you previously copied from Hotjar into the text field.
Click Choose a trigger to make this tag fire...
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.
Continue onto the next step to make sure Google Tag Manager and Hotjar are working together properly.
Once Your Tracking Code is Installed
You can start using any of the Hotjar tools: Heatmaps, Recordings, Surveys, and Incoming Feedback. Have a look at the guides below to get started.
- How to Start Continuous Heatmaps
- How to Start Continuous Recordings
- Creating Your First Survey
- Starting to use Incoming Feedback