pageTracker is no longer tracking my goals in Google Analytics
May 7, 2011 9:20 amLeave your thoughts
A while ago I noticed the sudden demise of the goal tracking across several websites I manage in Google analytics – one day the goals just died!� Fortunately in my analytics account I had made a note (using the lovely annotations you can add to your timeline) that this occurred at the exact same time I had updated the analytics code on those sites. Coincidence, no! In order to track the submission of forms and clicks on ‘mailto’ links across several websites I had setup some goals in Google Analytics. The goals were set to trigger everytime a specific URL was requested using a head match.� To track this on my pages I used the following javascript on form submission buttons:
<input name=”submit” type=”submit” id=”submit” value=”submit” onClick=”javascript:�pageTracker._trackPageview(‘/enquiry-form-sent’)” />For a mailto links I used the following:
<a href=”mailto:[email protected]?subject=Website Enquiry” onClick=”javascript:�pageTracker._trackPageview(‘/enquiry-email-link’)”>However since Google updated to the latest iteration of it’s asynchronous tracking code the syntax for tracking page views has changed. If you have updated to the latest version of the Google analytics code you will also need to update your pageTracker code.� For forms I now use:
<input type=”submit” name=”submit” id=”submit” value=”Submit” onClick=”javascript:�_gaq.push([‘_trackPageview’, ‘/enquiry-form-sent’]);” />And for mailto links:
<a href=”mailto:[email protected]?subject=Website Enquiry” onClick=”javascript:�_gaq.push([‘_trackPageview’, ‘/enquiry-email-link’]);”>… and once again your goals will be tracked and reported in Google analytics.� I’m sure this was probably mentioned somewhere in the literature about migrating to the new tracking code, but really, who reads all that! If you’re unsure which version of Google’s tracking code you are using you can read more here.
Categorised in: Web Development
This post was written by WillyNilly