阅读此文档后:https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#enhancedecom
我正在尝试将数据发送到谷歌分析:
$data = array(
"v" => 1,
"tid" => "XX-xxxxx-x",
"cid" => "999",
"t" => "pageview",
"dh" => "mydemo.com",
"dp" => "/receipt10",
"dt" => "Receipt%20Page10",
"ti" => "T12367",
"ta" => "Google%20Store%20-%20Online",
"tr" => 40.39,
"tt" => 2.85,
"ts" => 5.34,
"pa"=>"purshase",
"tcc" => "SUMMER2013",
"pr1id" => "P1265445",
"pr1nm" => "Android%20Warhol%20T-Shirt 2",
"pr1ca" => "Apparel",
"pr1br" => "Google",
"pr1va" => "Black",
"pr1ps" => 2);
$content = http_build_query($data);
$content = utf8_encode($content);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://ssl.google-analytics.com/collect");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, utf8_encode($content));
//curl_setopt($ch,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
这是部分工作:我在实时视图中获得了一个热门,我可以在“所有页面”视图中看到该页面,但在电子商务视图中没有任何内容。
我缺少什么?
答案 0 :(得分:1)
你需要等待。数据显示在标准报告中需要24-48小时。它仍在处理中。
如果它实时工作,那么明天你可能会在电子商务中看到它。
答案 1 :(得分:0)
不确定是否已经捕获到该错误,但是示例中写为“ pa” =>“购买”
的属性“ purchase”中有错字如果未正确描述此事件,则可能无法拾取其他属性。