[Yanel-dev] Sending custom data to Google Analytics

Balz Schreier balz.schreier at gmail.com
Mon Mar 28 15:02:47 CEST 2011


Dear all,
just a little update on this here, I am trying out 2 custom variables.
As you can see in the snippet below, the first integer in the parameter list
of the push() method is the index of the custom parameter.

I found out this here now:
- Once you have chosen that index "2" represents your user account type
(e.g. registered, premium), you should never change it anymore because
google merges all values received under index 2.

- Officially Google says that there is a *limitation of up to 5 custom
variables*:
http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#setup

- But it seems that you can override it:
*pageTracker._setMaxCustomVariables(10);*

If the last point is true, you can send as many custom fields to Google
Analytics, theoretically.
You also read, and this is now the practical point of view: the total number
of characters that you can send to GA is 2048. So there is anyway a limit,
independent of how many custom variables you are sending.

Cheers
Balz


On Fri, Mar 25, 2011 at 11:44 AM, Balz Schreier <balz.schreier at gmail.com>wrote:

>  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/20110328/23338e2a/attachment.html>


More information about the Yanel-development mailing list