Par*_*ner 3 google-analytics node.js google-api-nodejs-client google-apis-explorer
dataLayer我正在将一个简单的电子商务对象推送到客户端的Google 跟踪代码管理器。它工作正常,但我需要将其移至服务器。
我找到了Google API Node.js 客户端库,但它还很年轻,我找不到任何有效的示例。
有人设法做到这一点吗?如何使用 node.js 中的 google-api-nodejs-client 完成以下任务?
dataLayer.push({
event: 'purchase',
user: 'user_1234',
transactionId: 'trans_123',
transactionAffiliation: 'Acme Clothing',
transactionTotal: 11.99,
transactionProducts: [
{
id: '1234',
sku: 'SKU47',
name: 'Fluffy Pink Bunnies',
price: 11.99,
quantity: 1
}
]
});
Run Code Online (Sandbox Code Playgroud)
我认为你不需要这个或那个库的 google API。您只需使用Google 测量协议即可。
因此,对于您的数据层帖子,它将类似于:
对于交易
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=1234 // user_1234.
&t=transaction // Transaction hit type.
&ti=123 // transaction ID. Required.
&ta=acmeClothing // Transaction affiliation.
&tr=11.99 // Transaction revenue.
Run Code Online (Sandbox Code Playgroud)
然后该项目命中
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=1234 // Anonymous Client ID.
&t=item // Item hit type.
&ti=123 // Transaction ID. Required.
&in=fluffy pink bunnies // Item name. Required.
&ip=11.99 // Item price.
&iq=1 // Item quantity.
&ic=sku47 // Item code / SKU.
Run Code Online (Sandbox Code Playgroud)