krizon / php-ga-measurement-protocol

PHP client for the Google Analytics Measurement Protocol API
MIT License
109 stars 23 forks source link

Google Analytics Measurement Protocol PHP Client

Build Status Scrutinizer Quality Score Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

A full featured php client for the Google Analytics Measurment Protocol API. Build upon the shoulders of the great Guzzle.

See https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide

Installation

Use Composer to add this library to your dependencies:

$ composer require krizon/php-ga-measurement-protocol

Features

Usage

$config = array(
    'ssl' => true // Enable/Disable SSL, default false
);
$client = Krizon\Google\Analytics\MeasurementProtocol\MeasurementProtocolClient::factory($config);
$client->pageview(array(
    'tid' => 'UA-XXXX-XXXX', // Tracking Id 
    'cid' => 'XXXX-XXXXX-XXXXX', // Customer Id
    'dh' => 'domain.do',
    'dp' => '/php-ga-measurement-protocol/phpunit-test',
    'dt' => 'PHP GA Measurement Protocol'
));

Testing

Before you can run the tests make sure you installed the dependencies using composer:

$ composer install

PHPUnit itself is included in the dependencies so now you can call:

$ vendor/bin/phpunit

We have two types of tests:

Contributors