Google analytics as extension

Google analytics, next to page tracking etc, has the option for tracking
outbound links. It’s a very handy feature to use rather than another
tracking software. A simple implementation of it is simple by changing
a:

http://davidseah.com/blog/the-printable-ceo-series/

into

http://davidseah.com/blog/the-printable-ceo-series/

Is anyone working on an implementation of Google Analytics? If not I
would like to claim it to build my first extension.

Jasper

Jasper,

What do you think about using javascript for that? That would be my
choice.

It’s pretty easy with this jquery plugin :
http://jamazon.co.uk/web/2008/03/26/jquery-google-analytics-tracking-api-integration-gajs/

Marcus

Hi Marcus,

How is the above ga tracking different from the new ga.js? That’s the
one I’m using on my wordpress where I can specify by means of a pluging
van joost de valk.

Here is the screenshot of the settings in wordpress for example using
the ga.js to tag:

http://screencast.com/t/l3orhxHo3wq

I’m not trying to reinvent the wheel, just measuring on a website what’s
working and what’s not.

the outbound tag in
pageTracker._trackPageview(‘outbound/The Printable CEO™ Series – DSri Seah’)
and simply be replaced by a preset or specified one. I’ve checked the
analytics and the tagging works well that way.

The only thing is that the JS code needs to be loaded before the
pageTracker is being called.

So I’m going through the tutorial in creating an extension at the summer
reboot http://wiki.radiantcms.org/Creating_an_extension_I

Jasper

Hi Jasper,
just in case you or anyone else on the list is on a fruitless search to
also implement event tracking as part of your work with ga.js, it would
appear that this is still in beta. The event stuff is well documented,
but I had to dig around to find out why I wasn’t seeing anything
appearing in the GA reports. You need to apply to get on the Trusted
Tester program to get this switched on for your account
http://code.google.com/apis/analytics/docs/trustedTester.html

Event docs are here (basically same as pages but with additional
parameters, which you might find useful)

regards

Ben

Adam van den Hoven wrote:

for (var i = links.length - 1, lnk; i >= 0; i–){
the anchors this way is the fastest possible way to do it.

Jasper
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant

Ben Still | Red Ant | office +612 9267 8300 ext 208 | mobile 0425
294 271

Jasper,

I believe that Marcus’ point was that instead of hard coding it into
the HTML, that you write some JavaScript code to do it for you.
Something like this should be more than fast enough for your needs:

(function (){
//Always isolate your JavaScript from the global scope
var links = document.getElementsByTagName(“a”),
this_host = window.location.host;
for (var i = links.length - 1, lnk; i >= 0; i–){
lnk = links[i];
if (lnk.host !== this_host) {
lnk.onClick = “pageTracker._trackPageview('outbound/” +
lnk.href + “’);”
};
};
})();

I haven’t tested it but it should work, more or less correctly. You
could use a library to set the event, if you like, but looping through
the anchors this way is the fastest possible way to do it.

Adam