客户端到服务器端 google analytics MP 客户端 ID

Client side to server side google analytics MP client ID

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

这让我很头疼试图跟踪通过网上商店服务器端而不是客户端进行的交易。但我仍然想将交易与进行购买的唯一访问者 ID 相关联,而不仅仅是每次随机的客户 ID。

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

GA1.2.1586737968.1429871710 

documentation for getting cookie and user identification 声明如下:

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.

... 这对我没有帮助,因为我必须在服务器端执行此操作。不过不管怎么说,这个client ID连description of what a client ID looks like, although it does appear to match a legacy format都装不下。有点。

然后有几个问题:

  1. 我需要从 _ga cookie 中解析并作为客户端 ID 发送的只是最后两个数字 1586737968.1429871710 吗?还是一切都还好?
  2. 有没有 scripts/libraries 可以为我做这件事,这样我就不必担心 Google 突然给新访客提供基于新 UUID v4 格式的客户端 ID?
  3. 这种方法有什么明显的缺陷吗?

答案:

  1. 是的,正如您正确指出的那样,cid 值应该只是最后 2 个数字。 (这是已经持续成功使用 Measurement Protocol 的客户端设置的经验)
  2. 不,据我所知,最好自己做。只需几行代码即可检测您在 cookie 中看到的格式以及内容,因此您需要发送。
  3. 不是真的。这是一个很常见的场景。