[英]Cannot receive events from Google Measurement Protocol (Google Analytics v4)
I created an app in Firebase, and then found my target app (NodeJS CLI, Chrome extension, VSCode extension) could not use Firebase SDK, then I found the Google Measurement Protocol.我在Firebase创建了一个app,然后发现我的目标app(NodeJS CLI,Chrome扩展,VSCode扩展)无法使用 Firebase SDK,然后我找到了Google Measurement Protocol。 And it turns out to be frustrating and failed to get events to show up in the console.事实证明这很令人沮丧,无法让事件显示在控制台中。
My request passed /debug/mp.collect
:我的请求通过了/debug/mp.collect
:
fetch(
`https://www.google-analytics.com/mp/collect?api_secret=${SECRET}&firebase_app_id=${FIREBASE_APP_ID}`,
{
method: 'POST',
body: JSON.stringify({
app_instance_id: ${INSTANCE_ID},
events,
}),
}
)
api_secret
我遇到的第一个问题是找到api_secret
Official doc says: 官方文档说:
An API SECRET generated in the Google Analytics UI.在 Google Analytics UI 中生成的 API SECRET。 To create a new secret, navigate to: Admin > Data Streams > choose your stream > Measurement Protocol > Create要创建新机密,请导航至:Admin > Data Streams > 选择您的 stream > Measurement Protocol > Create
OK then comes into firebase: OK然后进入firebase:
const firebaseConfig = {
apiKey: "xxx",
authDomain: "dev-ext.firebaseapp.com",
databaseURL: "https://dev-ext.firebaseio.com",
projectId: "test",
storageBucket: "dev-ext.appspot.com",
messagingSenderId: "123",
appId: "xxx",
measurementId: "xxx"
};
Looks like is this apiKey
, and I tried, not working.看起来是这个apiKey
,我试过了,没有用。
Then I found someone says use the secret here:然后我发现有人说在这里使用秘密:
And I tried, not working.我试过了,没有用。
app_instance_id
, what the hell is this?第二个问题是app_instance_id
,这到底是什么?Here is the original doc:这是原始文档:
No clues for web and NodeJS case at all, and the ios, android links are pointing to Firebase SDK method.根本没有 web 和 NodeJS 案例的线索,ios、android 链接指向 Firebase SDK 方法。 I was like "WTF, why will I read this if I could use the Firebase SDK?"我当时想“WTF,如果我可以使用 Firebase SDK,我为什么还要读这个?”
So I tried a generated uuid.所以我尝试了一个生成的uuid。 And obviously, it's not working.显然,它不起作用。
I have the same, issue.我有同样的问题。 Ended up adding a new stream on analytics.google.com
and switching to gtag.js
.最后在analytics.google.com
上添加了一个新的 stream 并切换到gtag.js
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.