duanpu2272
2015-11-03 15:58
浏览 76
已采纳

客户端到服务器端的谷歌分析MP客户端ID

I am trying to send transaction data to UA from a webshop which is only creating orders once it has received a "push" from a payment processing API. A success page is displayed to the customer independently from the order being created, meaning the tracking script (UA via GTM with data layer) does not have access to the order data.

This gives me the headache of trying to track transactions made through the webshop server side, instead of client side. Yet I still want to tie the transaction to the unique visitor ID who made the purchase, not just a random Client ID each time.

My site is using analyics.js (UA profile). Therefore I thought somewhere a client ID would be stored as a cookie, and I do see a _ga cookie there which I believe is the client ID, which looks like this:

GA1.2.1586737968.1429871710 

The documentation for getting cookie and user identification states the following:

You should not directly access the cookie analytics.js sets, as the cookie format might change in the future. Instead, developers should use the readyCallback to wait until analytics.js is loaded, and then get the clientId value stored on the tracker.

... which is not helpful to me, as I have to do this server side. But anyway, this client ID does not even fit the description of what a client ID looks like, although it does appear to match a legacy format. Sort of.

Couple of questions then:

  1. Is it just those last two numbers 1586737968.1429871710 that I need to be parsing from the _ga cookie and sending as a client ID? Or is the whole thing ok?
  2. Are there any scripts/libraries that will do this for me so I don't have have to worry about Google suddenly giving new visitors the client ID based on the new UUID v4 format?
  3. Does this approach have any obvious flaws?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试从网上商店向UA发送交易数据,这只是在收到“推送”后才创建订单 “来自支付处理API。 成功页面独立于正在创建的订单显示给客户,这意味着跟踪脚本(通过带有数据层的GTM的UA)无法访问订单数据。

这给了我 试图跟踪通过网店服务器端而不是客户端进行的交易的头痛。 然而,我仍然希望将交易与进行购买的唯一访客ID相关联,而不是每次都是随机的客户ID。

我的网站使用的是analyics.js(UA配置文件)。 因此,我认为某个地方客户端ID将存储为cookie,我确实在那里看到一个_ga cookie,我相信它是客户端ID,如下所示:

  GA1  .2.1586737968.1429871710 
   
 
 

获取cookie和用户标识的文档说明如下:

您不应直接访问cookie analytics.js集, 因为cookie格式将来可能会改变。 相反,开发人员应该使用readyCallback来等待,直到加载analytics.js,然后获取存储在跟踪器上的clientId值。

...这不是 对我有帮助,因为我必须做这个服务器端。 但无论如何,此客户端ID甚至不适合描述什么是 客户ID看起来像,虽然它似乎与传统格式。 排序。

然后提出几个问题:

  1. 是否只需要解析的最后两个数字1586737968.1429871710 _ga cookie并作为客户端ID发送? 或者整件事情还可以吗?
  2. 是否有任何脚本/库可以帮我这样做,所以我不必担心Google突然给新访客提供基于新客户的ID UUID v4格式?
  3. 这种方法是否有明显的缺陷?
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsizd368332 2015-11-03 17:06
    已采纳

    Answers:

    1. Yes the cid value should just be the last 2 numbers as you rightly point out. (this is experience from client setups that already successfully use Measurement Protocol on an ongoing basis)
    2. Nope, not as far as I am aware, best to do it yourself. It will only be a few lines of code to detect what format you're seeing in the cookie and what, therefore you need to send through.
    3. not really. It is a common enough scenario.
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题