views:

265

answers:

1

I am trying to figure out how to use my google analytics account, and do custom tracking on certain links and such, but following the technical information on the help site on google isn't getting me anywhere. Has anyone done something like this? Point me in the right direction.

UPDATE This is the code, I am not seeing the results in my analytics account yet, but I am not getting errors now.

In header:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXX']); //Commented Out for posting
  _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';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();

</script>

THen on the href of my link I put this:

onclick="_gaq.push(['_trackEvent', 'Link Sponsored', 'Clicked Sponsored']);"

Is this the Correct Way to do it via asyc ga code?

+1  A: 

I can't find the problem from your code.

A couple of things:

  1. have you enabled "Event Tracking"? This must be set in your "Profile"

  2. While watching HTTP header activity using, for instance, the Firefox add-on "Live HTTP Headers", look for requests to the _utm.gif. To do this:

    • open the LiveHTTP Headers Panel;

    • then select the "Config" tab;

    • then check "Filter URLs with regexp;

    • type _utm.gif in the text box next to the box you just chekecked; and

    • select the "Generator" tab to record the activity.

doug
It seems to work, just took a few hours to appear.
matthewb