Google Analytics code, how does it work?

From here: http://www.google.com/support/analyticshelp/bin/answer.py?hl=en&answer=1136920

<script type="text/javascript">
function recordOutboundLink(link, category, action) {
  try {
    var myTracker=_gat._getTrackerByName();
    _gaq.push(['myTracker._trackEvent', ' + category + ', ' + action + ']);
    setTimeout('document.location = "' + link.href + '"', 100)
  }catch(err){}
}
</script>

If you notice that + categories + and + action + are in quotation marks. So how does the analytics script get its values?

+5
source share
1 answer

This is a mistake in their documentation; their code will not work properly.

This line should read:

_gaq.push(['myTracker._trackEvent',  category ,  action ]);

You're right. The way they do it has a category and an action passed as literal strings, not the passing of variables that contain strings in them.

+2
source

All Articles