[Yanel-dev] Sending custom data to Google Analytics

Balz Schreier balz.schreier at gmail.com
Fri Mar 25 11:44:43 CET 2011


Hi Michael,

as just discussed, Google Analytics allows you to send any kind of custom
data together with the default fields that Google Analytics sends:

A code example:
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-######-#']);

*  _gaq.push(['_setCustomVar',1,'Account Type','Trial', 1]);
  _gaq.push(['_setCustomVar',2,'User Type','Admin', 1]);
*
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript';
ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : '
http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
  })();

so via _gaq.push you could send meta data of viewed Yanel pages to Google
Analytics too (instead or in parallel to the boost log).

and an API also exists to access later the statistics data:
http://code.google.com/apis/analytics/docs/gdata/home.html

I have never tried out to send custom data but this sounds really
interesting.

Cheers
Balz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wyona.org/pipermail/yanel-development/attachments/20110325/2538f569/attachment.html>


More information about the Yanel-development mailing list