Download the PHP package clippings/php-gacx without Composer
On this page you can find all versions of the php package clippings/php-gacx. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download clippings/php-gacx
More information about clippings/php-gacx
Files in clippings/php-gacx
Package php-gacx
Short Description Server-side GA Content Experiments
License LGPL-3.0+
Homepage https://github.com/thomasbachem/php-gacx
Informations about the package php-gacx
Server-Side GA Content Experiments
While this is a standalone library, you might also be interested in the companion project for general server-side Google Analytics tracking: php-ga.
About
php-gacx is basically Google's cx/api.js in PHP: A server-side implementation that allows you to control and implement Content Experiments entirely on the server.
This is done by parsing experiment data to make use of GA's multi-armed bandit algorithm as well as programmatically modifying the "__utmx" and "__utmxx" cookies.
This does however depend on Google Analytics being used in the browser, see "Usage" below.
This library might become obsolete as soon as Google implements Content Experiments into their Measurement Protocol.
Requirements
Requires PHP 5.3+ as namespaces and closures are used. Has no other dependencies and can be used independantly from any framework or whatsoever environment.
Usage Example
All methods match the ones from the JS API, so using php-gacx is pretty straightforward if you've experience with cx/api.js:
In order to have the experiment data transferred to Google Analytics, you need to use
Google Analytics on the client side either via the traditional ga.js
or Google's new
analytics.js
(Universal Analytics).
ga.js
will work out of the box, as it simply consider and include the "__utmx"
cookie value when sending tracking data to Google Analytics.
analytics.js
does sadly no longer consider the "__utmx" cookie. You will therefore
have to tell it via Javascript which variation of an experiment has been chosen, and
it's limited to one experiment per page. Example:
The advantage of using php-gacx here is still that you can choose the variation on the server-side while still making use of the multi-armed bandit algorithm considering the variation's different weights.
Disclaimer
Google Analytics is a registered trademark of Google Inc.