0

阅读此文档后: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);

这是部分工作:我在实时视图中获得了成功,我可以在“所有页面”视图中看到该页面,但在电子商务视图中什么也看不到。

我错过了什么?

4

2 回答 2

1

您将需要等待。数据需要 24 - 48 小时才能显示在标准报告中。它仍在处理中。

如果它是实时工作的,那么您明天可能会在电子商务下看到它。

于 2017-08-02T14:27:00.163 回答
0

不确定您是否已经发现了这一点,但是您在示例中写为“pa”=>“purshase”的属性“purchase”中有错字

如果没有正确描述此事件,则可能不会拾取其他属性。

于 2019-05-09T16:37:11.927 回答