英文:
Custom event GA4 - Event parameter key is missing
问题
I am pushing an event from the server using an httpPost request in C#.
我正在使用C#中的httpPost请求从服务器推送事件。
I'm not sure what is missing, but I don't see the 'event' parameter key when I push the event.
我不确定缺少什么,但在推送事件时我没有看到'event'参数键。
The event count appears to be correct.
事件计数似乎是正确的。
Here is my JSON.
这是我的JSON。
{"client_id":"server","events":{"name":"API_call","params":{"items":[{"method":"GetLicenceDetails"}]}}}
这是我的JSON。
Here is my c# code to push the data. It's work well, and the GA4_Endpoint is properly formatted.
这是我用于推送数据的C#代码。它运行良好,GA4_Endpoint格式正确。
// endpoint : "https://www.google-analytics.com/mp/collect?measurement_id={0}&api_secret={1}";
using (var httpClient = new HttpClient())
{
var data = SerializationHelper.SerializeToJson(analyticContainer);
//https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=gtag#payload_post_body
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
var e = await httpClient.PostAsync(GA4_Endpoint, new StringContent(data, Encoding.UTF8, "application/json"));
return e;
}
在GA4中,为什么当我点击事件时没有事件参数键?它不应该显示
method
这是我的实时显示。
英文:
I am pushing an event from the server using an httpPost request in C#.
I'm not sure what is missing, but I don't see the 'event' parameter key when I push the event.
The event count appears to be correct.
Here is my JSON.
{"client_id":"server","events":{"name":"API_call","params":{"items":[{"method":"GetLicenceDetails"}]}}}
Here is my c# code to push the data. It's work well, and the GA4_Endpoint is properly formatted.
// endpoint : "https://www.google-analytics.com/mp/collect?measurement_id={0}&api_secret={1}";
using (var httpClient = new HttpClient())
{
var data = SerializationHelper.SerializeToJson(analyticContainer);
//https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=gtag#payload_post_body
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
var e = await httpClient.PostAsync(GA4_Endpoint, new StringContent(data, Encoding.UTF8, "application/json"));
return e;
}
Why in GA4 when i click on the event there is no event parameter key ? It's not supposed to show
> method
That is my realtime show.
答案1
得分: 1
这是你的JSON
{
"client_id":"server",
"events":{
"name":"API_call",
"params":{
"items":[
{
"method":"GetLicenceDetails"
}
]
}
}
}
这是来自GA4测量协议文档的JSON副本
https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#recommended_parameters_for_reports
{
"client_id": "x",
"events": [
{
"name": "offline_purchase",
"params": {
"engagement_time_msec": "100",
"session_id": "123"
}
}
]
}
我能快速看到的问题是你的JSON中有一个包含你期望参数的item
数组。也许你的JSON正确版本如下:
{
"client_id":"server",
"events":{
"name":"API_call",
"params":{
"method":"GetLicenceDetails"
}
}
}
但我只是好奇为什么你的JSON中有一个item
。这是从用于电子商务的JSON复制过来的吗?
英文:
Here is your JSON
{
"client_id":"server",
"events":{
"name":"API_call",
"params":{
"items":[
{
"method":"GetLicenceDetails"
}
]
}
}
}
Here is the JSON copy from the GA4 Measurement Protocol Document
https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag#recommended_parameters_for_reports
{
"client_id": "x",
"events": [
{
"name": "offline_purchase",
"params": {
"engagement_time_msec": "100",
"session_id": "123"
}
}
]
}
The quick thing I can see is you have a item
array which contains the parameter you expected.
So maybe the right version from your JSON is
{
"client_id":"server",
"events":{
"name":"API_call",
"params":{
"method":"GetLicenceDetails"
}
}
}
But just curious about why there is a item
in your JSON. Is it copy from the JSON which using for ecommerce?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论