I have got this html on the page:
<a href="review.asp?sitename=webcamking#video_embed" class="tutorials" data_site="webcamking"> Tutorial 1</a>
This jquery:
$('.tutorials').click(function(event){
event.preventDefault();
event.stopPropagation()
var linkText=$(this).text();
var siteName= $(this).attr('data_site');
alert("Test. linkText:"+linkText+". siteName:"+siteName);
_gaq.push(['_trackEvent', 'LinkClicked', siteName, linkText]);
//window.location.href=$(this).attr('href');
return false;
})
The problem is that the link still keeps sending me to the destination. I need to stop it. I need to check what I get with the alert..and hope the google analytics event is triggered!!
Update: Modified code:
$(document).ready(function(){
$('.tutorials').click(function(event){
event.preventDefault();
var linkText=$(this).text();
var siteName= $(this).attr('data_site');
alert("Test. linkText:"+linkText+". siteName:"+siteName);
_gaq.push(['_trackEvent', 'LinkClicked', siteName, linkText]);
//window.location.href=$(this).attr('href');
return false;
});
$( document ).ready( function() {})statement?