Yii Framework Forum: Google Serverside Analityics - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Google Serverside Analityics Rate Topic: ***** 1 Votes

#1 User is offline   Nodalizer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 13-March 12

Posted 15 November 2012 - 07:25 PM

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.
0

#2 User is offline   Nodalizer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 13-March 12

Posted 15 November 2012 - 10:03 PM

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.
0

#3 User is offline   Nodalizer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 13-March 12

Posted 15 November 2012 - 11:51 PM

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

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users