使用测量协议的GA4转换跟踪
[编辑。添加了代码样本和更多解释]
有人熟悉GA4测量协议吗?
我们使用GA4测量协议将事件从后端服务器发送到服务器端GTM容器。除了转换跟踪外,一切都很好。如果我们通过MP发送这些事件,则标记为转换的事件不算为转换(默认“购买”事件除外,它可以很好地工作)。如果我们从浏览器(客户端GTM)发送相同的参数的相同事件与转换相同。由于我在网上找不到有关此问题的任何信息,唯一剩下的就是使用服务器端GTM预览模式通过参数调试参数。在这里,我发现,如果我从浏览器发送事件,则我在其查询字符串中标记的事件的请求我标记为GA中的转换“& _c = 1”。
据我所知,这意味着要通过MP获得转换事件,事件请求需要具有“ _C”查询字符串参数。我尝试将“ _C”添加为事件参数,但这无效。是否有指定的JSON参数将事件标记为转换?
-------------更多信息---------------
这是事件“专家”的示例。此事件从客户端和服务器发送。正如您在屏幕截图中看到的那样,此事件被标记为转换。
conversions&questions” page'page'>
您在第二个屏幕截图上可以看到,实际事件(137)远胜于检测到的转换(48)。区别正是从服务器端发送的。
evertivure> evests&quot” page'>
这是服务器呼叫的请求主体:
{
"client_id":"Z9TLWnyVC2UK4UssPIVk8J+2n5BZhgWLtWSlFYYSwlg=.1642076344",
"user_id":"119412",
"events": [{
"name": "Experts",
"params": {
"tenweb_action": "[Test action]",
"tenweb_info": "[Some more info]",
"debug_mode":1,
"page_location": "https://10web.io/[some-test-page]"
}
}]
}
[Edited. Added code sample and more explanations]
Is anybody familiar with the GA4 Measurement Protocol?
We are sending events from our backend servers to the server-side GTM container using the GA4 Measurement Protocol. Everything works fine except for conversion tracking. The events marked as conversion are not counted as conversions if we send those via MP (except for the default "purchase" event, it works perfectly). The same event with the same parameters counts as a conversion if we send it from the browser (client-side GTM). As I couldn't find anything about this issue online, the only thing left was to debug parameter by parameter using the server-side GTM preview mode. Here I discovered, that if I send events from the browser, the requests for events I mark as conversions in GA have "&_c=1" in their query string.
That means, as far as I understand it, that in order to get conversion events via MP, the event request needs to have "_c" query string parameter. I tried adding "_c" as an event param, but that didn't work. Is there a designated JSON parameter to mark the event as a conversion?
------------MORE INFO--------------
Here is an example of an event "Experts". This event gets sent from both the client-side and the server. As you can see in the screenshot, this event is marked as a conversion.
As you can see on the second screenshot, the actual events (137) are much more than the conversions detected (48). The difference are exactly the ones sent from the server-side.
Here is the request body of the server call:
{
"client_id":"Z9TLWnyVC2UK4UssPIVk8J+2n5BZhgWLtWSlFYYSwlg=.1642076344",
"user_id":"119412",
"events": [{
"name": "Experts",
"params": {
"tenweb_action": "[Test action]",
"tenweb_info": "[Some more info]",
"debug_mode":1,
"page_location": "https://10web.io/[some-test-page]"
}
}]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Jan,@daimto和其他所有可能会有这个问题的人。
我想我找到了解决方案。尽管这是非正式的,并且可能随时破裂,但这是我到目前为止发现的最好的。这是我最终所做的。虽然我注意到通过GTM预览模式进行调试,但在事件数据转换事件的选项卡中,有一个对象“ x-ga-system_properties” ,在其他系统变量中,包含
c:“ 1”
。因此,我尝试将我们发送到服务器端GTM的测量协议端点的事件参数JSON。
它起作用。以这种方式发送的事件被GA4注册为转换。
很高兴听到您对此的想法。您认为这是一个稳定的解决方案吗?您是否认为Google会有有关此的官方文件?
@Jan, @DaImTo, and everyone else that might have this issue in the future.
I think I've found a solution. Although it's unofficial and might break at any moment, it's the best one I've found so far. Here is what I ended up doing. While debugging via GTM preview mode I noticed, that in Event Data tab of conversion events there is an object "x-ga-system_properties", that, among other system variables, contains
c:"1"
. So I tried addingto the event parameters JSON that we send to the Measurement Protocol endpoint of our server-side GTM.
IT WORKED. The events sent that way were registered as conversions by GA4.
Would be great to hear your thoughts on this. Do you think it's a stable solution? Do you think there will be official documentation on this from Google?