[Extension] (TP) Google Analytics

This is the discussion thread for the (TP) Google Analytics extension.

Basic Overview

I’ve finished up development of the first of many different extensions to implement various web analytic tools (Google Analytics, Yahoo! Web Analytics, Adobe SiteCatalyst, etc.) I’ve specialized in web analytics for the past 3 years and my aim with these extensions is to help other developers get the most data into their web analytic tools as easily as possible. This first extension is for Google Analytics which is a fairly straight-forward tool.

Where can I download/see documentation for this?

Since I’m under the required 10 (?) posts on the forum I cannot post in the Extensions directory… however, I do have everything up on Google Code. Perhaps a moderator could edit this to include the URL, ha. Search for the project “yii-analytics” or add /p/yii-analytics to the end of code.google.com This is where all of the analytic-related extensions I create will be hosted in the event you use something other than Google Analytics.

What I’m looking for

I’m looking for feedback pretty much everything, but mainly around the ease of use and the performance of the extension for you.

Go and publish your extension on the extensions’ portal of Yii :)

Consider it added! http://www.yiiframework.com/extension/tp-google-analytics/

What is the best way to deal with dev/test sites? There is no way to disable the extension globally - do you just use different filters/profiles to separate out the sites?

Also, interested in knowing if you’re using any special magic for attaching events to button/link clicks…etc. Seems like there isn’t really an elegant way to do it, other than adding a script block to each view and jq binding to the element id.

Thanks for the extension!

rhomb from yii IRC had a great idea for attaching events to elements:

maybe something like:

Yii::app()->googleAnalytics->attachEvents(array('#mylink' => array('Videos', 'Play', 'Baby\'s First Birthday')));

Hey PrplHaz4 -

There are a few ways of dealing with dev sites.


[*]Leave the configuration as-is on site, and filter into different profiles in GA

[*]Use different configuration files to send to different web properties in GA

[*]Use different configuration files to send data to a dummy account ID (e.g. UA-000000-0). You can still see the requests being sent to GA, but won’t see any data in any reports (since the account doesnt exist).


Re: Links, that is one way to do it. I’ll tinker with it.

Thanks Philip, very helpful!


I encounted a problem with _trackEvent on functions with $this->redirect as the code would never be printed to a document, thus never sendt to ga.js.

Is there a good way to handle this?

I was toying with the possibility to add a function similar to the flashmessages, but with eventTrackings instead. That way you could execute all trackings done in the controller, even to you redirect.

I hit a dead end, cus i cant seem to get a handle on multiple entries to one setState name.

Something to add, what do you think?

Thanks for a great extension!