[英]GA Conversions link transaction to client id theiconic/php-ga-measurement-protocol
[英]PHP problems with Google Analytics E-commerce: theiconic/php-ga-measurement-protocol
我正在使用theiconic / php-ga-measurement-protocol程序包,并已按照自述文件中所述的确切步骤进行操作,但是由于我不太了解的原因,有一半的信息未显示在Google Analytics(分析)中。
我正在使用以下代码:
use TheIconic\Tracking\GoogleAnalytics\Analytics;
$trackingID = 'xxxxxxx';
$order = 'obviously an object';
$deal = 'object';
$analytics = new Analytics();
// the Client ID just won't do anything
$analytics->setProtocolVersion('1')
->setClientId($order->gaClientID)
->setTrackingId($trackingID);
// this part works just fine
$analytics->setTransactionId($transactionID)
->setRevenue($order->getTotalPrice(false))
->setTax($order->getTaxCost())
->sendTransaction();
// here it's as if nothing happens
// Yes, it does loop over all the orderRules but it does not show up in Google Analytics
foreach ($order->getOrderRules() as $orderRule) {
$analytics->setTransactionId($transactionID)
->setItemName($deal->name)
->setItemCode($order->dealID)
->setItemCategory($deal->getDealCategoryName())
->setItemPrice($orderRule->getPrice())
->sendItem();
}
我将使用此JavaScript的ClientID保存到隐藏的输入中:
ga.getAll()[0].get('clientId')
所以我的问题基本上是:
我有什么要忘的吗? 我有好几个人在看它,却无法找出问题出在哪里。
我会怎么做:
增强型电子商务 :用用于增强型电子商务的代码替换旧的电子商务代码 。 原因:新(增强)与旧版本向后兼容,并且具有许多其他功能,因此使用旧电子商务的得分为0。 原因2:增强的电子商务实现看起来“更干净”,因为所有数据最后都->sendEvent();
一次就发送了( ->sendEvent();
),而旧的电子商务首先发送了交易(- > sendTransaction();),然后再使用单独的匹配项( ->sendItem();
)添加产品。
侦错 :启用侦错模式以找出是否/为什么您的匹配被API拒绝。
通过增强型电子商务,它应该类似于:
$analytics->setDebug(true)
->setEventCategory('Checkout')
->setEventAction('Purchase')
->sendEvent();
$debugResponse = $response->getDebugResponse();
print_r($debugResponse);
而且您应该从如下所示的API获得调试 :
{
"hitParsingResult": [
{
"valid": false,
"hit": "GET /debug/collect?tid=fake\u0026v=1 HTTP/1.1",
"parserMessage": [
{
"messageType": "ERROR",
"description": "The value provided for parameter 'tid' is invalid. Please see ... for details.",
"parameter": "tid"
},
我再次尝试了增强型电子商务。 我之前也做过,但是这次启用了调试功能。 如hitPersingResult [0] ['hit']所示,可以正确发送客户端ID。 但在Google Analytics(分析)中仍然没有任何内容。
同样,我们没有达到极限。 我从字面上复制了粘贴示例,这是我的回应:
Array
(
[hitParsingResult] => Array
(
[0] => Array
(
[valid] => 1
[parserMessage] => Array
(
)
[hit] => /debug/collect?v=1&tid=UA-xxxxxxxx-11&cid=161460xxxx.xxxx180000&uid=161460xxxx.xxxx180000&ti=1802.48511-1518713633&ta=test%20affiliation&tr=206.95&tt=3.4623966942149&ts=0&pa=purchase&ec=Checkout&ea=Purchase&t=event&pr1id=2033&pr1nm=xxxxx&pr1br=brand&pr1ca=xxxxxx&pr1pr=xxx&pr1qt=1
)
)
[parserMessage] => Array
(
[0] => Array
(
[messageType] => INFO
[description] => Found 1 hit in the request.
)
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.