简体   繁体   English

将 Google Analytics 测量 ID 与 React JS 集成

[英]Integrate Google Analytics Measurement Id with React JS

I am creating a new web project in Google Analytics.我正在 Google Analytics 中创建一个新的网络项目。

  1. Why am i getting a Measurement iD instead of Tracking ID?为什么我得到的是测量 ID 而不是跟踪 ID?
  2. How can i connect Measurement ID with React JS?如何将测量 ID 与 React JS 连接?
  3. Can i give localhost URL in website URL?我可以在网站 URL 中提供 localhost URL 吗?

I have added below code in my App.js but it is not getting integrated with Google Analytics我在 App.js 中添加了以下代码,但它没有与 Google Analytics 集成

useEffect(() => {
  ReactGA.initialize('G-*******SYL');
  ReactGA.pageview('/');
}, [])

I suggest you create a Universal Analytics Property (as shown in following image) and use the relative identifier UA-XXXXXXX-X because Google Analytics 4 Property ID (G-XXXXXXXX) currently has the measurement protocol in alpha version, also React does not support it yet:我建议您创建一个Universal Analytics Property(如下图所示)并使用相对标识符 UA-XXXXXXX-X 因为 Google Analytics 4 Property ID (G-XXXXXXXX) 目前有 alpha 版本的测量协议,React 也不支持还没完成:

在此处输入图片说明

Create a new property, with selected "Create a Universal Analytics property".创建一个新媒体资源,并选择“创建 Universal Analytics 媒体资源”。 It'll show you tracking id.它会向您显示跟踪 ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 React 应用程序中将 Google Analytics 与到达路由器集成 - Integrate Google Analytics with reach router in React application Gtag 和 Google Analytics 事件和网页浏览量衡量 - Gtag and Google Analytics events and page view measurement 如何将Google Calendar API与React JS集成? - How to Integrate Google Calendar API with React JS? Google Analytics(分析)追踪js程式码无法在React中运作 - Google analytics tracking js code not working in React 如何在 Gatsby.js 中为 Google Analytics 添加多个跟踪 ID? - How to Add multiple Tracking ID for Google Analytics in Gatsby.js? 将购物车价值整合到 google pay 中的 react js - integrate shopping cart value in google pay in react js 在React.js中可视化Google分析数据,编辑json - Visualizing google analytics data in React.js, editing json react.js 谷歌分析不起作用。 没有显示实时数据 - react.js Google analytics not working. no realtime data is shown React.js 中的谷歌分析对象和数据层的区别 - Difference google analytics object and dataLayer in React.js React JS网站上的Google Analytics输出不正确的数据(会话中断?) - Google Analytics on React JS site outputting incorrect data (broken sessions?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM