8 Tips for Tracking With Google

Click tracking

If you are tracking clickthrus, events, conversions using Google Analytics here are a few tips, ideas and hints for tracking and then later on improving your webpage using Google tools : analytics, adwords and Google website optimizer.

New to Google Analytics is something called event tracking. Google events are slightly different than goals in Google analytics and while Google suggests that you track using events – I could find no easy way / interface to see which keyword is generating a desired event – like a click thru or a sale with events. This leaves  us with a  doing both tracking events and generating goals to have the best desired result.

  1. Here are some ideas for best practices for click tracking on an affiliate website.
  1. Install Jquery – this is easy to do ( 1 line of  lightweight javascript) . Why ? Because you can use jquery to track all similiarly named outgoing links. See how tiny jquery is by clicking here.
  2. Redirect / rename all affiliate link simliarly –  I am using a plugin called gocodes – it seems pretty good and I am sure their are others. But the point is that you want to track every click thru and you want all the links you are tracking to look the same.  So you want all affiliate links to look  like /recommends/ or /go/ , etc. To be consistent but also because of the tracking code provided below and because of Tip number 3
  3. Setup goals for click thrus on Google Analytics – If you are following point number two above you can easily set a goal for all links that match  /recommends/.+ ,  /go/.+ or whatever syntax you use.
    analytics goals

    analytics goals

    Even better if you can track both click thrus and goals but for right now – just do clickthru tracking –  An article to reference — http://analytics.blogspot.com/2009/05/how-to-setup-goals-in-google-analytics.html

  4. Install this tracking code to track all click that match  your syntax.
    [cc lang=”javascript” tab_size=”2″ lines=”40″]
    var $a=jQuery(this);
    var href=$a.attr(‘href’);
    {var category=’outgoing’;
    var event=’click’;
    var label=href;
    This kind of tracking code matches all outgoing links with the keyword /recommends/ and will generate a goal proivded you did the previous steps for 2 and 3. To change this syntax to another naming convention is easy enough. This code also generates both a goal and an event in analytics.
    Thanks to  these contributers listed- for this idea — rebeccamurphey , think2loud and css-tricks
    If this is too complicated then manually insert page tracking — http://www.johncow.com/google-analytics-creating-goals/
  5. To track conversions in adwords or to assign conversions to click thrus you could just click add this code snippet below[cc lang=”javascript” tab_size=”2″ lines=”40″]
    var image = new Image(1,1);
    image.src = “http://www.googleadservices.com/pagead/conversion/XXXXXXX/?value=1&label=Purchase&script=0”;
    [/cc] This just initiates an image pixel so that a conversion in adwords is generated.

    So now you have tracking for goals, events and possibly adwords conversion events setup for your website done easily provided that you name , cloak and redirect your links in all the same fashion

  6. Now if you want to try and improve your webpage – you might try this – Counting a conversion when a link is clicked with website optimizer Here is the essential code [cc lang=”javascript” tab_size=”2″ lines=”40″]Download the file[/cc]
  7. If you are looking to improve , decrease page bounce rates – then you might try optimizing pages using webiste optimizer for a version that keeps people on your website longer — Here are the details – http://www.google.com/support/websiteoptimizer/bin/answer.py?hl=en&answer=74345
  8. Stuck with how to setup a landing page ? Here is a simple optin idea for lead pages – landing page generator – very simple but you get the idea here or even better monitor adwords campaigns that are working with a tool like traffic travis.

By implementing these tips you should be able to track and improve your webpage’s effectiveness with Google tracking tools.  Leave a comment below if this helps you!


  1. minette roos says

    I sure wish I had stumbled apon anything close to this article months ago.. I can’t believe how much relevant information I’ve just viewed alltogether!

    Thank You

    Minette Roos

  2. says

    This was exactly what I was looking for – event tracking in combination with gocodes.
    Unfortunately I just can´t get it to work.
    You use the basic tracker-code twice. Once with google Analyticator for wordpress, inkluding the event-line and once without – does that the trick?
    Best regards

  3. says


    You are right on this website I am using it twice I need to fix that. On other websites I use it just once which does the trick.

    I have it working on another which website are you trying to track ?

  4. says

    Well, hello again!
    Thanks for your reply!!
    I copied the code and put my syntax in. (hopefully in the right way, I guess I´ll have to check the /\ combination in /?anbieter=\// again).
    After it ran for a night I´ll see if it works that way.
    I will let you know!
    Take care,
    regards from germany

  5. says

    Marco yes I changed the slashes so that it matches go/ but more importantly these two lines were changed

    var $a=jQuery(this);

    to use jQuery instead of $ because wordpress uses jquery but with JQuery.noConflict – very technical but using the new syntax this should work ..

    I suggest setting up a click thrus as a goal also are you doing that too ?

    Good Luck with your site

  6. says

    That ist technical 😉 – and I´m just not a programmer.
    So, I at first did not change the jquery.js – now I did.
    And yes: I set up the click thrus as goals.
    I´ll tell you tomorrow if it now worked!
    thanks&take care!

  7. says

    marco I looked at your site

    You should change this line

    I dont think its going to work as you have it now..

    You are not using Gocodes it appears do you have another tracking program ?

    Also put a javascript alert to test if tracking is working right away

    so do
    if(href.match(/?anbieter=/)){ alert(“working”); and then remove the alert(“working”) once you have confirmed it is working

  8. says

    It indeed did not work. Unfortunately once I put the line into the analyticator google analytics doesn´t track anything anymore.

    I do use gocodes, but it is a modified version of that plugin. The bad part about that is, that I cant change the “?anbieter=” in “/anbieter/”. Do you think the parameters ? and = could cause Problems?

    This alert idea is a good one, I´ll experiment with that and your suggestion of syntax.
    thanx and take care!

  9. says

    Hm, hm… I don´t get it. The alert at least doesnt work.
    And I forgot to say: Yes, I have a goal set up – and tried it in those different combinations like

    the latter I try to use with “;if(href.match(/?anbieter=)” (since that is the typical part of the gocodes Links. (like for example: http:// www. partneragentur-vergleich.de/?anbieter=PartnerSite)

    I somehow run out of ideas…

  10. says

    hi Macro

    are you familiar with regular expression matching ?

    that is what is going on there in the href.match() statement

    change this line

    to href.match(/anbieter/) and you should see the alert .. you are almost there

    Let me know if that works and if not contact me via the contact form and I could login to your wordpress system and adjust it but I think all you need to do lookin at you r page is to
    change this line

    to href.match(/anbieter/)

  11. says

    Hello Fields,
    (by the way – I didn´t quite figure out your first name was Fields in that combination. I guess you probably here that sometimes?!)

    I tried to bite my way through the regular expression matching, but maybe I got the two slashes wrong. I now changed to (href.match(/anbieter/) and the regular expression matching to /anbieter/.+
    hopefully that´ll do it.

    Have a good weekend!

  12. says

    I just tried for the alert using Internet Explorer (normally FireFox) there it shows that the error occurs in the line 456 “pageTracker._trackPageview();”

    > so i guess it might be still rather the code than the regular expression matching, what do you think?

  13. says

    Hi marco,

    I am not seeing this work on your page I think because anything after the ? is technically a querystring and so a href.match only matches the hyperlink


    There does not seem to be a way to match the query string easily that I know of but I know very little of jquery

    too bad you cant do the standard way that gocodes normally work .. it appear you will half to embed javascript on each affilate redirect link onClick= pageTracker._trackPageview(); something like that

    sorry I do not have easy answer for you

  14. says

    Good Morning Fields,
    maybe I will have to start using the “normal” GoCodes. I will take a closer look at it – and if I find a way I let you know!
    Have a good week – and thanks again!!
    Take care –

Leave a Reply

Your email address will not be published. Required fields are marked *