PHPackages                             ommu/gapi-google-analytics-php-interface - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ommu/gapi-google-analytics-php-interface

ActiveOmmu-extension[Utility &amp; Helpers](/categories/utility)

ommu/gapi-google-analytics-php-interface
========================================

Google Analytic PHP Interface from Ommu Platform

1.0.1(8y ago)06701Apache-2.0PHPPHP &gt;=5.3.2

Since Sep 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ommu/ext-gapi)[ Packagist](https://packagist.org/packages/ommu/gapi-google-analytics-php-interface)[ Docs](https://github.com/ommu/ext-gapi)[ RSS](/packages/ommu-gapi-google-analytics-php-interface/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

GAPI now has OAuth2 support
===========================

[](#gapi-now-has-oauth2-support)

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

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

```
$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.

Download the latest [gapi.class.php](https://github.com/erebusnz/gapi-google-analytics-php-interface) and try out the filter control with the example.filter.php. Read more about the [GAPI Filter Control](https://github.com/erebusnz/gapi-google-analytics-php-interface/blob/wiki/UsingFilterControl.md).

Features:
---------

[](#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.

Need google analytics interface in your OO PHP5 project?

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.

Use is as simple as:
--------------------

[](#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 ''.$result.'';
  echo 'Pageviews: ' . $result->getPageviews() . ' ';
  echo 'Visits: ' . $result->getVisits() . '';
}

echo 'Total pageviews: ' . $ga->getPageviews() . ' total visits: ' . $ga->getVisits() . '';

```

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

Access metrics and dimensions using magic get methods
-----------------------------------------------------

[](#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.

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

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

```

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

[](#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.

1. Create a [Google Developers project](https://console.developers.google.com/project)
2. Create service account under this project, [see instructions](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount)
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 &gt; User Management*, give the service account 'Read and Analyse' permissions on the analytics accounts you want to access

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 65.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1338 days

Total

3

Last Release

473d ago

Major Versions

1.0.1 → v2.x-dev2025-01-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc55e183fd0f46f18cd61df9e536dda16be7db49036b180542e64dc414e22c25?d=identicon)[ommu](/maintainers/ommu)

---

Top Contributors

[![erebusnz](https://avatars.githubusercontent.com/u/6275189?v=4)](https://github.com/erebusnz "erebusnz (34 commits)")[![PutraSudaryanto](https://avatars.githubusercontent.com/u/5587049?v=4)](https://github.com/PutraSudaryanto "PutraSudaryanto (16 commits)")[![neurofuzzy](https://avatars.githubusercontent.com/u/99393?v=4)](https://github.com/neurofuzzy "neurofuzzy (1 commits)")[![renatoaquino](https://avatars.githubusercontent.com/u/516453?v=4)](https://github.com/renatoaquino "renatoaquino (1 commits)")

---

Tags

google-analyticsommu-extensionphp-interfaceyiiyii2googleplatformextensionanalyticsgoogle-analyticsgaommuommu-platform

### Embed Badge

![Health badge](/badges/ommu-gapi-google-analytics-php-interface/health.svg)

```
[![Health](https://phpackages.com/badges/ommu-gapi-google-analytics-php-interface/health.svg)](https://phpackages.com/packages/ommu-gapi-google-analytics-php-interface)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[fof/analytics

Tracks analytics using Google Analytics, Google Optimize/GTM and Matomo

3543.1k](/packages/fof-analytics)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
