2017 © Pedro Peláez
 

library php-ga-measurement-protocol

Easy use of the Google Analytics Measurement Protocol in PHP

image

krizon/php-ga-measurement-protocol

Easy use of the Google Analytics Measurement Protocol in PHP

  • Friday, October 9, 2015
  • by krizon
  • Repository
  • 8 Watchers
  • 112 Stars
  • 259,053 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 26 Forks
  • 9 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

Google Analytics Measurement Protocol PHP Client

Build Status Scrutinizer Quality Score Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

A full featured php client for the Google Analytics Measurment Protocol API. Build upon the shoulders of the great Guzzle., (*2)

See https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide, (*3)

Installation

Use Composer to add this library to your dependencies:, (*4)

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

Features

  • Page tracking
  • Event tracking
  • Ecommerce tracking
  • Social interactions tracking
  • Exception tracking
  • User timing tracking
  • App tracking
  • Non-blocking requests (todo)

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:, (*5)

$ composer install, (*6)

PHPUnit itself is included in the dependencies so now you can call:, (*7)

$ vendor/bin/phpunit, (*8)

We have two types of tests:, (*9)

  • Tests with mocked 200 OK response, @group __nogroup__. This type of tests are used tor testing required fields, asserting classtypes etc.;
  • Tests that do real calls to the Google API, @group internet. The Google API itself always returns a 200 OK so to be sure the requests are transferred and handled correctly you can run the tests of group 'internet'. Before running this group make sure you've configured the correct tracking id in the phpunit.xml configuration by setting the env variable tracking_id. This group is excluded by default but you can run this tests by calling: $ vendor/bin/phpunit --group internet

Contributors

The Versions

09/10 2015

dev-master

9999999-dev

Easy use of the Google Analytics Measurement Protocol in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kristian Zondervan

09/10 2015

v1.0.0

1.0.0.0

Easy use of the Google Analytics Measurement Protocol in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kristian Zondervan

28/04 2014

dev-async-requests

dev-async-requests

Easy use of the Google Analytics Measurement Protocol in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kristian Zondervan

08/04 2014

0.1.0

0.1.0.0

Easy use of the Google Analytics Measurement Protocol in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kristian Zondervan