简体   繁体   English

如何从 Google Analytics 4 获取视图 ID?

[英]How do I get View ID from Google Analytics 4?

I tried to retrieve all information about my website from GA (Google Analytics).我试图从 GA (Google Analytics) 检索有关我网站的所有信息。 I'm using laravel and this package https://github.com/spatie/laravel-analytics to make my life easier.我正在使用 laravel 和这个 package https://github.com/spatie/laravel-analytics让我的生活更轻松。 However, that package requires "View ID" from GA, which I can't help myself to find it.然而,那个 package 需要 GA 的“查看 ID”,我无法帮助自己找到它。 I read this thread https://support.google.com/analytics/thread/15684521?hl=en and I'm guessing that since GA 4 they totally removed the views column from Web + App property (which will be created as a default) (correct me pls).我读了这个线程https://support.google.com/analytics/thread/15684521?hl=en我猜从 GA 4 开始,他们完全从 Web + App 属性(将创建为默认)(请纠正我)。 Did anyone had this problem before?以前有人遇到过这个问题吗? Where I can find that "view id"?在哪里可以找到“视图 ID”? are there some articles that can help me solve this problem?有一些文章可以帮助我解决这个问题吗? Any suggestion about better way to achieve my goal?关于实现我的目标的更好方法的任何建议?

In GA4 there aren't Views so you if you want to use your code (who needs a View), you have to create a Universal Analytics Property.在 GA4 中没有视图,因此如果您想使用您的代码(需要视图),您必须创建一个 Universal Analytics Property。

You can find it by clicking on Show advanced options (when you create a new property):您可以通过单击Show advanced options找到它(当您创建新属性时):

在此处输入图像描述

For anyone using GA4, you must use Google Analytics Data API instead of Reporting API. Use the same oauth scopes and you can use already issued token.对于任何使用 GA4 的人,您必须使用Google Analytics Data API而不是 Reporting API。使用相同的 oauth 范围,您可以使用已经发布的令牌。 This is the sample http request (post):这是示例 http 请求(发布):

https://analyticsdata.googleapis.com/v1beta/properties/[property id]:runRealtimeReport

with example body:示例正文:

{
  "metrics": [{ "name": "activeUsers" }]
}

which gives you simple result.这给你简单的结果。 Keep in mind that metrics are different, there are now no totalUsers.请记住,指标是不同的,现在没有 totalUsers。 Use this list which has all allowed metrics and you can find dimensions on the same page.使用此包含所有允许指标的列表,您可以在同一页面上找到维度。

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

相关问题 用户使用Google oauth登录时如何获取用户的组织ID? - How do I get a user's organization id when they login with Google oauth? 我如何在 laravel 中获取帖子 ID - How do i get a post id in laravel 如何从附加到特定user_id的数据透视表中获取记录到其他表中 - how do I get records from pivot table attached to specific user_id into other table 如何从订单 Controller 到 laravel 中的订单项目 Controller 获取新创建的 ID - How do I get a newly created ID from the Order Controller to the Order Item Controller in laravel 如何从授权客户端获取我的user_id - How do I get my user_id from the authorised client 使用 spatie/laravel-analytics,如何获取特定 pagePath 的页面浏览量? - Using spatie/laravel-analytics, how do I get page views for a specific pagePath? Laravel 如何从多个控制器获取信息到一个视图中 - Laravel how do I get info from several Controllers into ONE view 如何在Laravel(PHP)中将对象从一个视图传递到另一个视图? - How do i pass an object from view to view in Laravel (PHP)? 如何在Laravel应用中获取客户端ID? - How do I get the client id in a Laravel app? 如何根据数组 php 中的 id 获取数据 - How do i get data based on the id in the array php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM