This library provides a PHP interface for the Universal Analytics Measurement Protocol, with an interface modeled (loosely) after Google's analytics.js.
Future releases will support an interface similar to ga.js, for legacy implementations which already integrate our legacy library.
NOTE that this project is still beta; some features of the Measurement Protocol aren't fully represented, and new features will be added in the (hopefully) nearer future. Please feel free to file issues for feature requests.
Email: opensource@analyticspros.com
For the most accurate data in your reports, Analytics Pros recommends establishing a distinct ID for each of your users, and integrating that ID on your front-end web tracking, as well as back-end tracking calls. This provides for a consistent, correct representation of user engagement, without skewing overall visit metrics (and others).
A simple example:
<?php
require('universal-analytics.php');
$t = new Tracker(/* web property id */ 'UA-XXXXX-Y', /* client id */ 'abc', /* user id */ null);
$t->set('dimension1', 'pizza');
$t->send(/* hit type */ 'event', /* hit properties */ array(
'eventCategory' => 'test events',
'eventAction' => 'testing',
'eventLabel' => '(test)'
));
?>Currently all tracking hits (using send) require an array (dictionary) of properties related to the hit type.
- Throttling
- GA Classic interface
We're particularly interested in the scope of throttling for back-end tracking for users who have a defined use-case for it. Please contact us if you have such a use-case.
universal-analytics-php is licensed under the BSD license