Forked from dmolsen/Add Google Analytics to jQTouch Project
Created
May 12, 2010 12:27
-
-
Save jordandobson/398519 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$('#jqt').ajaxComplete(function(){ | |
add_ga(); // add google analytics on each page load | |
}); | |
$(document).ready(function() { | |
add_ga(); // add google analytics to the first page | |
}); | |
function add_ga() { | |
$('a').each(function(){ | |
if (!$(this).hasClass('ga')) { | |
if ($(this).attr('data-ga')) { | |
//$(this).click(function(){console.log('had data ga click 2');}); | |
$(this).click(function(){pageTracker._trackPageview($(this).attr('data-ga'))}); | |
$(this).addClass('ga'); | |
} else { | |
if ($(this).attr('href') == '#') { | |
//$(this).click(function(){console.log('back button 2');}); | |
$(this).click(function(){pageTracker._trackPageview('/'+$(this).attr('href')/+'/')}); | |
$(this).addClass('ga'); | |
} else { | |
//$(this).click(function(){console.log('internal link 2');}); | |
$(this).click(function(){pageTracker._trackPageview($(this).attr('href'))}); | |
$(this).addClass('ga'); | |
} | |
} | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment