【问题标题】:How to insert Hotjar code to nuxt project如何将 Hotjar 代码插入 nuxt 项目
【发布时间】:2020-05-07 07:47:17
【问题描述】:

我想将 hotjar 添加到我的 nuxt 项目中。我知道要添加谷歌分析,我需要根据 nuxt 的文档将其添加为插件:https://nuxtjs.org/faq/google-analytics。但我不知道将 htjar 添加到项目中的最佳方法是什么。

【问题讨论】:

    标签: nuxt.js hotjar


    【解决方案1】:

    我的做法与 google-analytics 文档相同。

    1. 将 hotjar 添加到 nuxt.config 中的插件:

      插件:[ {src:'~/plugins/hotjar.js',模式:'client'} ]

    2. 将 hotjar.js 文件添加到您的插件目录中,其中包含您的跟踪代码。

    我也很好奇有没有更好的办法

    【讨论】:

    • 试试这个: // nuxt.config.js { // ... plugins: ['~/plugins/hotjar'] } 然后将实现代码(不带脚本标签)添加到 plugins/hotjar .js // plugins/hotjar.js (function (h, o, t, j, a, r) { 你的代码... }
    • 另一种选择是通过谷歌标签管理器中的标签实现 hotjar。 @ShadiFarzankia
    猜你喜欢
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 2021-09-04
    • 2021-02-27
    • 2014-12-13
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    相关资源
    最近更新 更多