PHPackages                             matthiew/phpga - 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. [API Development](/categories/api)
4. /
5. matthiew/phpga

ActiveLibrary[API Development](/categories/api)

matthiew/phpga
==============

Google analytics vendor for symfony2

046PHP

Since Sep 5Pushed 13y ago1 watchersCompare

[ Source](https://github.com/Matthiew/Symfony2GoogleAnalyticsVendor)[ Packagist](https://packagist.org/packages/matthiew/phpga)[ RSS](/packages/matthiew-phpga/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Server-Side Google Analytics PHP Client
=======================================

[](#server-side-google-analytics-php-client)

Important
---------

[](#important)

This package is directly based on this project from UnitedPrototype :

This package is aimed at using php-ga in symfony 2 as a vendor and a service.

Summary :
---------

[](#summary-)

"ga.js in PHP" - Implementation of a generic server-side Google Analytics client in PHP that implements nearly every parameter and tracking feature of the original GA Javascript client.

We love Google Analytics and want to contribute to its community with this PHP client implementation. It is intended to be used stand-alone or in addition to an existing Javascript library implementation.

It's PHP, but porting it to e.g. Ruby or Python should be easy. Building this library involved weeks of documentation reading, googling and testing - therefore its source code is thorougly well-documented.

The PHP client has nothing todo with the Data Export or Management APIs, although you can of course use them in combination.

Requirements
------------

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

Installation :
--------------

[](#installation-)

**In your deps file :**

```
[php-ga]
    git=http://github.com/t0k4rt/Symfony2GoogleAnalyticsVendor.git

```

**Update your vendors :**

```
php bin/vendors

```

**Update your autoload.php file :**

```
$loader->registerNamespaces(array(
    ...
    'GoogleAnalytics'         => __DIR__.'/../vendor/php-ga/src',
    ...
));

```

**In your config.yml / config\_dev.yml / config\_prod.yml :**

To use this as a service add the following lines

```
parameters:
    php_ga.class:      GoogleAnalytics\Tracker
    php_ga.accountID:  UA-12345678-9
    php_ga.domain:  yourwebsite.com

services:
    php_ga:
        class:        %php_ga.class%
        arguments:    [ %php_ga.accountID% , %php_ga.domain% ]

```

**In your bundle :**

You now can include the class in your controller

```
use googleanalytics;

```

And track page (or events etc.) :

```
// Initilize GA Tracker
$tracker = $this->get('php-ga');

// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
$visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
$visitor->setScreenResolution('1024x768');

// Assemble Session information
// (could also get unserialized from PHP session)
$session = new GoogleAnalytics\Session();

// Assemble Page information
$page = new GoogleAnalytics\Page('/page.html');
$page->setTitle('My Page');

// Track page view
$tracker->trackPageview($page, $session, $visitor);

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/22fd904db1ead403999b800e99d055e28330afdb4d345ba6ab447bb4781aba9c?d=identicon)[MatthiewF](/maintainers/MatthiewF)

---

Top Contributors

[![Matthiew](https://avatars.githubusercontent.com/u/1763663?v=4)](https://github.com/Matthiew "Matthiew (3 commits)")[![t0k4rt](https://avatars.githubusercontent.com/u/498106?v=4)](https://github.com/t0k4rt "t0k4rt (1 commits)")

### Embed Badge

![Health badge](/badges/matthiew-phpga/health.svg)

```
[![Health](https://phpackages.com/badges/matthiew-phpga/health.svg)](https://phpackages.com/packages/matthiew-phpga)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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