Linus Larsson

Importing HotJar data into Google Analytics

Are you using HotJar to get valuable insights of what your visitors are doing on your website? I bet you wouldn't mind getting that data integrated with Google Analytics to make even more advanced analyses. This post is basically an extension to a post that one of my colleague, Eivind Savio,  wrote some time ago. If you implement the tracking in Google Tag Manager as he recommends in his post, then you will be able to do what I'm gonna show you now.

So first I'm gonna give you an example of two use cases in order for you to understand the value of this. First off, let's say you have five big personas that you use in your marketing and website strategies. Wouldn't it be cool to be able to create segments of those personas in Google Analytics? With this method that will be possible. Just make sure that the questions you ask in the survey or poll can define the user as a persona!

The second use case is if you are measuring NPS (Net Promoter Score) on your website and would like to be able to analyze the traffic based on the loyalty level from the NPS poll. So how do we do this in an easy way?

Step 1

Make sure you implement the tracking that is necessary in Google Tag Manager, as described in this blog post.

Step 2

Set up a poll or a survey in HotJar. In this case I have set up a poll measuring NPS.

Step 3

Let the poll run for a while in order to get some results. Once you got some, you can start the process of importing it to Google Analytics. Create a new spreadsheet in Google Sheets and create some columns; one for "user" and one for each answer of the poll you created. In this case there will only be one question and therefore two columns in the sheet.

Step 4

Download your responses from HotJar as an XML.

Now you will need to copy the data from the downloaded file and paste it into the Google Sheet you created in step 3. You only have to use the columns that are relevant for the Sheet.

Now you have everything you need to make the data import. The key is going to bi the user ID, since you sent that data to Google Analytics in the tracking you created in step 1.

Step 5

Create a new custom dimension in Google Analytics. Make sure that you set it to the same scope as you did with the HotJar User ID. What we are going to do is that we're going to use the IDs in our sheet and then find them in Google Analytics. If we find a match, this new custom dimension will be populated with the value of our second column in the Sheet.

Step 6

Next up, we're going to import the data. Choose "Data import" at the bottom of the admin settings for property in Google Analytics. In "Data set type", choose "Custom data". Name the variable in a way that you will remember what it is and then choose which views should receive the HotJar data (I usually choose all views). Now you will be asked to select matching keys. As I wrote before this will be the HotJar User ID in Google Analytics and the "user" column in the Google Sheet, so choose the HotJar User ID in the first box.

In the second box you will have to pick the dimension to which you will send the imported data. Here you should pick the new dimension you just created.

That's it! You can now use the HotJar data in your new custom dimension to create more advanced reports, segments and dashboards. This is an easy way to gain more relevant insights into your users behaviour. Make sure to comment what you used the function for!


  1. Jenny

    2018-07-19 16:02

    Hi Linus,

    This was very helpful, thank you! I followed your instructions, but it seems I’m not able to “backfill” data from before creating my survey response custom dimension and importing my responses.

    I’ve been collecting HotJar User ID’s in GA for about a month using a session-scoped custom dimension. On 7/16, I created a new session-scoped custom dimension for my poll responses, and imported my month’s worth of responses and their HotJar IDs (as the key). It’s been about 4 days, and I’m only able to see data in my custom reports for the last 4 days, which seems to just be users that were matched coming back to the site after importing the data.

    Did I do something wrong here? Should I have created the custom dimension earlier on? From your article and Google’s documentation there’s no indication that the custom dimensions need to be created at a certain point to be able to match imported data to historical behavior. Any support you can provide would be helpful!

    • Linus

      2018-12-10 15:52

      Hi Jenny,

      Unfortunately I’m not sure exactly what went wrong but I have experienced the same kinf of problem in other situations. In those cases I have exported the data from both GA and the other source (in this case HotJar) to another place, e.g. Excel or R and merged the data there. If you specify how you set up the dimensions then maybe I can help troubleshoot for you. Perhaps you can attach screenshots?

Leave a Reply

Your email address will not be published. Required fields are marked *


Cookie Settings

© Copyright - - 2018-2024