Today I had to find some way to track the links within a page using Google Analytics, jQuery and Thickbox. With the new ga.js it is pretty straight forward:
$(function(){
if(typeof(pageTracker) != 'undefined') {
$('a.thickbox, area.thickbox, input.thickbox')
.click(
function(){
pageTracker._trackPageview(
$(this).attr('href')
);
}
);
}
}
);
No related posts.
2 Comments
Sorry I’m new to Javascript implementation.
I wanted to know where would you insert the above mentioned code. I assume in the header and if so then we need to add the other script from Google Analytics above this code or after this code.
Thanks in advance.
Regards,
Pali Madra
Actually, this code will run when the page is ready for interaction, and I would be pretty sure that adding this script to the head and leave Google Analytics code at the bottom (where the most people put the analytics script) will make it work 99% of the time. If someone clicks the thickbox link before the page is ready for interaction this script may miss to register. For a fool-proof solution, you probably have to load the analytics code in the head and then add a script inline to each and every anchor you would like to track, but that is an ugly solution.
3 Trackbacks
Google Reader Shared Items The evil of dropdown, flyout and pop-up menus (GUUUI – The interaction designers coffee break)Google Analytics(ga.js), <b>jQuery</b>, Thickbox and Stats(Google Blog Search: jquery)IE 8 now doesn’t trip on Acid (Ajaxian)Analyzing Timer Performance (John Resig)DOM Assistant updated to 2.5, adds CSS selector support (456 Berea Street)Theme Firefox On-the-Fly with Personas [Featured Firefox Extension]
[...] mit: Liste, List, jquery, SCREENshots, PlugIns, übersicht merken bewerten Google Analytics(ga.js), jQuery, Thickbox and Stats – The Frontend Du hast leider keinen oder keinen aktuellen Flash-Player installiert. Du kannst den aktuellen [...]
[...] 19:35Google Analytics(ga.js), jQuery, Thickbox and Stats – The Frontend – garycannone del.icio.us/tag/jquery — Analytics(ga.js) Frontend Google Stats The Thickbox and jQuery [...]