pf » Tracking JavaScript Events with Google Analytics
September 28, 2006
Tracking JavaScript Events with Google Analytics
Did you know that you can track JavaScript events with Google Analytics? I just found this out... It's pretty cool, because allows you to track things like outbound link clicks, AJAX calls, static files, and more.
It's quite simple to do, just call the urchinTracker function (make sure that your urchin code defined before and above calling this function), and pass in a url. It will then track log the url as if it were a regular page visit. So for example lets say you wanted to log downloads of a zip file...
<a href="stuff.zip" onclick="urchinTracker('/downloads/stuff');"> download </a>
You can use the same method to log a outbound link click...
<a href="http://adobe.com/" onclick="urchinTracker('/outgoing/adobe_com');"> adobe </a>
You should see /downloads/stuff and /outgoing/adobe_com in your reports within 24-48 hours.
Permalink | Add Comment |
add to del.icio.us
| Tags: google, analytics, javascript, ajax, urchintracker, urchin
add to del.icio.us
| Tags: google, analytics, javascript, ajax, urchintracker, urchin
Related Entries
- GoogleBot Runs AJAX? - December 6, 2006
- Adobe AIR Tutorial for HTML / JavaScript Developers - February 25, 2008
- Ext CFC - December 12, 2007
- Howto Build Server Side AJAX Suggestions with script.aculo.us - December 6, 2006
- Uploading Files Like GMail Attachments - October 6, 2006
Trackback Address: 586/97766722922239635163342147B73CC2
Comments
On 09/29/2006 at 9:00:52 AM MDT Dave Carabetta wrote:
1
Hey Pete, great tip! Just a quick note to let you know that your iframe code to display your code snippets is collapsed in IE (which is the engine my blog reader uses). You can't see the code at all unless you open the link in Firefox.
On 11/06/2006 at 10:13:27 PM MST LDD wrote:
2
Thank you so much for the download counter. It has been the only thing holding me back from using googlepages as my main storage center for files. This really sealed the deal. Thankyou Thankyou Thankyou
On 02/02/2007 at 2:51:50 PM MST Sonicko wrote:
3
Thank you for that suggestion. We operate a Google Analytics Consulting firm and I'll be sure to add this to our list of options with a link back to this thread. Our site is www.sonicko.com if you have any questions.
On 08/23/2007 at 11:46:37 AM MDT ziggy wrote:
4
Why do people always add "javascript:"? It's on a js onclick handler. Not needed.
On 12/05/2007 at 11:21:51 AM MST Andrea Canfield wrote:
5
I'm wondering if I can use this to track WITHIN a site - while I can use google navigation certainly, I'm thinking that this would be a more succinct manner to track say, a landing page to the product page.
- CFSCRIPT Cheatsheet
- 3 New Image Effects for ColdFusion 8
- Googlebot to Submit Web Forms
- ColdFusion 8 Update 1 Fixes some Image Processing Quirks
- 10 Most Useful Image Functions in ColdFusion 8
- Speaking at NYC CFUG This Week
- Adobe AIR Tutorial for HTML / JavaScript Developers
- INFORMATION_SCHEMA Support in MySQL, PostgreSQL
Subscribe to my RSS Feed:
RSS
RSS
Pete Freitag is a software engineer, and web developer located in










