I'm using the theiconic/php-ga-measurement-protocol package and have followed the exact steps as described in the readme, but for reasons I don't quite understand, half of the info does not show up in Google Analytics.
I'm using the following code:
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();
}
And I'm saving the ClientID with this JavaScript into a hidden input:
ga.getAll()[0].get('clientId')
So my issues are basically:
- client ID does not work
- Items do not appear in Google Analytics Ecommerce
Is there anything I am forgetting? I've had several people looking at it, not being able to find out where it's going wrong.