如何使用 Javascript 自动标记 hotjar 视频

How to tag hotjar videos automatically using Javascript

我正在尝试从 google 优化中自动标记我们的 Hotjar 记录,以便我们可以更轻松地识别 A 或 B 用户。问题是我找不到任何地方解释如何做到这一点,official documentation 解释说你 可以 做到这一点,而不是如何去做,它只会继续解释如何手动完成。

如何使用 javascript 自动标记 Hotjar 录音?

来自官方documentation:

Recordings can be automatically tagged using a JavaScript code snippet. If your visitor visits any page which runs this JavaScript code, their Recording will be saved with the tag/s you set. To tag a Recording, add this JavaScript code:

hj('tagRecording', ['tag1', 'tag2']);

Doing so will cause all Recordings of visitors who pass through this page to include the two tags "tag1" and "tag2".


Important

If there is a chance that the code will be run before the Hotjar script has loaded, you must add this line of code just before.

window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};