I'm trying to track a particular section of links on my page. I want to know what is clicked, so I'm trying to set up a click handler with jQuery to register a custom variable with Google Analytics, but it's not working. Here's my code:
<!--Google Analytics-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18698622-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
$(function(){
$('a.link-item.bullet').click(function(){
_gaq.push(['_setCustomVar', 1, 'National Link', $(this).text(), 2]);
});
});
</script>
It's been about 3 or 4 days, and I haven't seen any custom variables register yet. Maybe I can't have include a variable ($(this).text()) in the custom variable? Anyone tried this before?