在nuxt.js中设置Google Analytics(分析)4 [英] setup Google Analytics 4 in nuxt.js

查看:254
本文介绍了在nuxt.js中设置Google Analytics(分析)4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用Nuxt设置新的Google Analytics(分析)4(GA4)帐户时遇到问题.根据教程,一切似乎都配置正确,但是我的流量未显示在GA(开发和生产)中

在nuxt.config.js中,我有以下内容

  buildModules:['@ nuxtjs/tailwindcss','@ nuxtjs/google-analytics'],谷歌分析: {id:'G-HWW3B1GM6W'}, 

google ID是我的生产网站的GA4数据流ID.我尝试了两种不同的视频流,分别使用www和不使用www,但GA4中没有显示访问量.

解决方案

[UPDATE]

如果您想使用GA4属性(ID为G-XXXXXXXXXX的格式),则可以尝试使用

I'm having issues setting up a new Google Analytics 4 (GA4) account with Nuxt. Everything seems configured ok based on tutorials, however my traffic doesn't show up in GA (dev & production)

In nuxt.config.js I have the following

  buildModules: [
    '@nuxtjs/tailwindcss','@nuxtjs/google-analytics'
  ],
  googleAnalytics: {
    id: 'G-HWW3B1GM6W'
  },

The google id is a GA4 Data Stream id with my production website. I tried 2 different streams, with www and without, but the traffic doesn't show up in GA4.

解决方案

[UPDATE]

If you want to use GA4 Property (which is what has the ids in the format G-XXXXXXXXXX) you can try to use vue-gtag package by creating a plugin.


About the problem indicated in your message, that plugin you mentioned works with the Universal version of Google Analytics (which is what has the ids in the format UA-XXXXXXXXX-X), like the example in your link:

 buildModules: [
   '@nuxtjs/tailwindcss','@nuxtjs/google-analytics'
 ],
 googleAnalytics: {
   id: 'UA-XXXXXXXX-X'
 },

The code you entered in the example, G-HWW3B1GM6W, refers to the new Google Analytics 4 which, being a different system from the previous one and does not work (yet) with that plugin.

So I suggest you to create a Universal Analytics type Property and use its ID (UA-XXXXX-X) with the plugin you indicated. You can find it by clicking on Show advanced options (when you create a new property):

这篇关于在nuxt.js中设置Google Analytics(分析)4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆