简体   繁体   English

客户端到服务器端Google Analytics MP客户端ID

[英]Client side to server side google analytics MP client 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. 我试图从网上商店向UA发送交易数据,该网上商店仅在收到来自付款处理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. 成功页面将独立于正在创建的订单显示给客户,这意味着跟踪脚本(通过带有数据层的GTM的UA)无法访问订单数据。

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. 但是,我仍然希望将交易与购买商品的唯一访客ID相关联,而不仅仅是每次都随机获得一个客户ID。

My site is using analyics.js (UA profile). 我的网站正在使用analyics.js(UA配置文件)。 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: 因此,我认为某个客户端ID将以cookie的形式存储,并且确实看到了一个_ga cookie,我相信这是该客户端ID,看起来像这样:

GA1.2.1586737968.1429871710 

The documentation for getting cookie and user identification states the following: 获取Cookie和用户标识文档规定以下内容:

You should not directly access the cookie analytics.js sets, as the cookie format might change in the future. 您不应该直接访问cookie analytics.js集,因为cookie格式将来可能会更改。 Instead, developers should use the readyCallback to wait until analytics.js is loaded, and then get the clientId value stored on the tracker. 相反,开发人员应使用readyCallback等待加载analytics.js,然后获取存储在跟踪器上的clientId值。

... 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 . 但是无论如何,尽管此客户ID看起来确实与旧格式匹配,但它甚至不符合客户ID的描述 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? 我需要从_ga cookie进行解析并作为客户端ID发送的仅仅是前两个数字1586737968.1429871710吗? 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? 是否有任何脚本/库可以为我完成此任务,所以我不必担心Google突然为新访问者提供基于新UUID v4格式的客户ID?
  3. Does this approach have any obvious flaws? 这种方法是否有明显的缺陷?

Answers: 答案:

  1. Yes the cid value should just be the last 2 numbers as you rightly point out. 是的,正如您正确指出的那样,cid值应该只是最后两个数字。 (this is experience from client setups that already successfully use Measurement Protocol on an ongoing basis) (这是来自客户端设置的经验,这些客户端设置已成功持续使用Measurement Protocol)
  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. 只需几行代码即可检测您在Cookie中看到的格式以及什么格式,因此您需要进行发送。
  3. not really. 并不是的。 It is a common enough scenario. 这是足够普遍的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM