【发布时间】:2017-05-26 10:05:04
【问题描述】:
我想将交易的产品利润推送到 Google Analytics。 有了这个,我想生成一个报告,我可以在其中查看产品总收入以及已订购的每种产品的利润。
我正在使用此 api 将自定义指标推送到分析 (Measurement protocol api)
我在分析中做了几个自定义指标,例如:
- Productsprofit(范围命中,小数)
- Productsprofit2(范围产品,十进制)
我已经用谷歌搜索了好几次,我认为我需要使用 Scope Hit 进行这种类型的跟踪,对吗?
我已使用 api 将具有正确索引的指标推送到 Analytics
$analytics->setTransactionId('test'.$orderId)
->setAffiliation('Testshop')
->setRevenue(number_format($orderTotalPrice,2,'.',''))
->setTax(number_format($taxTotal,2,'.',''))
->setShipping(number_format($shippingTotal,2,'.',''))
->setCouponCode('');
foreach($orderInfo['orderDetails'] as $orderDetail) {
// Include a product, only required fields are SKU and Name
$productData1 = [
'sku' => $orderDetail['model'],
'name' => $orderDetail['name'],
'brand' => '',
'category' => '',
'variant' => '',
'price' => number_format($orderDetail['price'], 2, '.', ''),
'quantity' => $orderDetail['aantal'],
'coupon_code' => '',
'position' => 0,
'custom_metric_3'=>50.45, //<-- test data (Hit)
'custom_metric_4'=>15.50 //<-- test data (Product)
];
$analytics->addProduct($productData1);
}
// Don't forget to set the product action, in this case to PURCHASE
$analytics->setProductActionToPurchase();
// Finally, you must send a hit, in this case we send an Event
$analytics->setEventCategory('Checkout')
->setEventAction('Purchase')
->sendEvent();
我创建了一个自定义报告并将这些指标添加到我的报告中。但在我的报告中,这两个指标都为空。
有谁知道我做错了什么?或者什么可以解决我的问题?
提前致谢!
【问题讨论】:
-
如果你想通过测量协议发送自定义指标,它应该看起来像这样
cm1=。你如何建立通话? developers.google.com/analytics/devguides/collection/protocol/… -
我正在使用这个 api github.com/theiconic/php-ga-measurement-protocol 。我认为您不需要在此 api 中为此添加 cm1=。
标签: google-analytics analytics metric