gpt4 book ai didi

nuxt.js - 如何在 Nuxt.js 中使用 Google 标签

转载 作者:行者123 更新时间:2023-12-04 15:07:50 25 4
gpt4 key购买 nike

我在 Nuxt.js 2.13 上,我想在我的项目中使用 Google 标签。
但是有几件事我不清楚!
第一:Nuxt.js 社区有两个 pi0 包,@nuxtjs/gtm@nuxtjs/google-gtag .我应该使用哪一种?
第二:如何使用dataLayer.push({'varName':'value'})用这些包?在他们的文档中,他们只说明了 push('event') .

最佳答案

关于第一点:

  • google-gtag-module 不推荐使用的 v1
  • gtm-module 新 v2

  • release notes 中所述:

    This is a major rewrite of @nuxtjs/google-tag-manager after 3 years of contributions and feedback from users.



    关于第二点,你必须使用 $gtm.push方法来制作您的推送事件或数据。
    例如,在您的 pages/index.vue文件:
    <script>
    export default {
    middleware ({ $gtm }) {
    $gtm.push({ 'varName': 'value' })
    }
    }
    </script>
    https://github.com/nuxt-community/gtm-module/tree/master/example 查看另一个完整的配置示例.

    关于nuxt.js - 如何在 Nuxt.js 中使用 Google 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65752819/

    25 4 0