Google Serverside Analityics

G’day people,

I was wondering if someone could point me in the right direction for implementing PHP-ga into YII.

I currently use it like:


use UnitedPrototype\GoogleAnalytics;


// Initilize GA Tracker

$tracker = new GoogleAnalytics\Tracker('UA-12345678-9', 'example.com');


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

I am not sure how to implement the USE UnitedPrototype\GoogleAnalytics; as for me to get it to work in my current non-yii sites I had to have it as the very first line of code.

Any help of how I get started on this would be much appreciated.

Even a hint will do.

I am stuck, don’t know where to go from here. Tried including and setting various alias, still no luck.

For anyone having troubles in the future I did the following:


<?php

/**

 * Controller is the customized base controller class.

 * All controller classes for this application should extend from this base class.

 */

class Controller extends CController

{

	protected function beforeRender($view)

	{

		Yii::setPathOfAlias('GoogleAnalytics',Yii::getPathOfAlias('application.vendors.phpGA.GoogleAnalytics'));

		return parent::beforeRender($view);

	}

And removed UnitedPrototype\ from all of the PHP-ga class file namespaces. I could not get it to work with that there.

And then use it as follows:


// Initilize GA Tracker

	$tracker = new GoogleAnalytics\Tracker('U&********&', 'www.HGGDD.FF.au');