Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing Hotjar User ID in Google Tag Manager & Google Analytics

We have a setup where we capture Hotjar User ID in Google Tag Manager and then pass it as a custom dimension to Google Analytics. It's done to simply merge and cross-reference both data sources.

We used the following code to capture the User ID:

function() { return hj.property.get('userId'); }

2 days back we stopped receiving the data, even though there haven't been any changes to Google Tag Manage, Google Analytics or our Hotjar account.

My suspicion is that there have been a system update on the Hotjar end. I had a chat with their technical support, but they were unable to help me.

Would be great if someone with more experience could have a look at the following file, to see if there is a way to capturing the 'userId' value:

https://script.hotjar.com/modules-397099a69f05558cbf66f164cffcaf65.js

Thanks

like image 467
TomG Avatar asked Nov 17 '16 00:11

TomG


2 Answers

Please try hj.pageVisit.property.get('userId'). This one has returned a proper userId for me today.

like image 135
Rainer Avatar answered Sep 22 '22 01:09

Rainer


As of FEB 2019 you can use the following to get the Hotjar User ID:

hj.globals.get("userId").split("-").shift()
like image 29
LR. Avatar answered Sep 20 '22 01:09

LR.