2017 © Pedro Peláez
 

ommu-extension gapi-google-analytics-php-interface

Google Analytic PHP Interface from Ommu Platform

image

ommu/gapi-google-analytics-php-interface

Google Analytic PHP Interface from Ommu Platform

  • Thursday, July 5, 2018
  • by ommu.co
  • Repository
  • 1 Watchers
  • 0 Stars
  • 413 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 83 Forks
  • 0 Open issues
  • 3 Versions
  • 121 % Grown

The README.md

GAPI now has OAuth2 support

GAPI is now at version 2.0 - This version has full OAuth2 and V3 authentication support., (*1)

Development is complete on the Google Analytics filter control. You can now filter your results using a simple GAPI filter string, for example:, (*2)

$filter = 'country == United States && browser == Firefox || browser == Chrome';

You can create simple query strings that represent the logic Google Analytics requires, but it is abstracted enough to be more readable and easier to work with., (*3)

Download the latest gapi.class.php and try out the filter control with the example.filter.php. Read more about the GAPI Filter Control., (*4)

Features:

  • Supports CURL and fopen HTTP access methods, with autodetection
  • PHP arrays for Google Analytics metrics and dimensions
  • Account data object mapping - get methods for parameters
  • Report data object mapping - get methods for metrics and parameters
  • Easy filtering, use a GAPI query language for Google Analytics filters
  • Full PHP5 Object Oriented code, ready for use in your PHP application

GAPI (said 'g,a,p,i') is the Google Analytics PHP5 Interface., (*5)

Need google analytics interface in your OO PHP5 project?, (*6)

You might be running symfony, zend framework, cakePHP and need a good object-oriented interface to get those stats. This class gives a good clean class based interface., (*7)

Use is as simple as:

$ga = new gapi('XXXX@developer.gserviceaccount.com','oauthkeyfile.p12');

$ga->requestReportData(145141242,array('browser','browserVersion'),array('pageviews','visits'));

foreach($ga->getResults() as $result)
{
  echo '<strong>'.$result.'</strong><br />';
  echo 'Pageviews: ' . $result->getPageviews() . ' ';
  echo 'Visits: ' . $result->getVisits() . '<br />';
}

echo '

Total pageviews: ' . $ga->getPageviews() . ' total visits: ' . $ga->getVisits() . ', (*8)

';

This project was inspired by the use of Doctrine and Propel ORM interfaces for PHP. Dealing with complex data should be easy!, (*9)

Access metrics and dimensions using magic get methods

With GAPI, when data is returned from Google it is automatically converted into a native PHP object, with an interface to allow the 'get' the value of any dimesion or metric., (*10)

For example, if you request the metric 'uniquePageviews' and the dimension 'pagePath' you can do the following:, (*11)

foreach($ga->getResults() as $result)
{
  echo $result->getUniquePageviews();
  echo $result->getPagePath();
}

Instructions for setting up a Google service account for use with GAPI

GAPI (because now Google Analytics API only supports OAuth2) will require you to create a 'service account' and then download a .P12 file to upload to your application., (*12)

  1. Create a Google Developers project
  2. Create service account under this project, see instructions
  3. Download the .p12 file for this service account, upload to the same folder as gapi.class.php
  4. Enable 'analytics API' in the Google Developers console
  5. In Google Analytics Administration > User Management, give the service account 'Read and Analyse' permissions on the analytics accounts you want to access

The Versions

05/07 2018

dev-master

9999999-dev https://github.com/ommu/ext-gapi

Google Analytic PHP Interface from Ommu Platform

  Sources   Download

Apache-2.0

The Requires

 

analytics extension platform google google analytics ga ommu ommu platform ommu-platform

06/01 2018

1.0.1

1.0.1.0 https://github.com/ommu/ext-gapi

Google Analytic PHP Interface

  Sources   Download

Apache-2.0

The Requires

 

analytics extension platform google google analytics ga ommu ommu platform

24/09 2017

1.0

1.0.0.0 https://github.com/ommu/ext-gapi

Google Analytic PHP Interface for Ommu Platform

  Sources   Download

Apache-2.0

The Requires

 

analytics extension platform google google analytics ga ommu ommu platform