2017 © Pedro Peláez
 

library phpga

Google analytics vendor for symfony2

image

matthiew/phpga

Google analytics vendor for symfony2

  • Wednesday, September 5, 2012
  • by MatthiewF
  • Repository
  • 1 Watchers
  • 0 Stars
  • 37 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Server-Side Google Analytics PHP Client

Important

This package is directly based on this project from UnitedPrototype : http://code.google.com/p/php-ga/, (*1)

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

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., (*3)

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., (*4)

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

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

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

Installation :

In your deps file :, (*8)

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

Update your vendors :, (*9)

php bin/vendors

Update your autoload.php file :, (*10)

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

In your config.yml / config_dev.yml / config_prod.yml :, (*11)

To use this as a service add the following lines, (*12)

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

You now can include the class in your controller, (*14)

use googleanalytics;

And track page (or events etc.) :, (*15)

// 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);

The Versions

05/09 2012

dev-master

9999999-dev http://github.com/Matthiew/Symfony2GoogleAnalyticsVendor

Google analytics vendor for symfony2

  Sources   Download

The Requires

  • php >=5.3.0

 

google-analytics php-ga