Hi Guys,
now this one is for the geeks... :-)
I have one website where a have lots of internal html anchors (links to sections on the same page - using xaras "link-to-anchor") and I have table-of-content grafical navigation bar which links to those sections.
Now in my tracking software (PIWIK) I would like to see if someone clicks on those anchors and I need to trigger a javascript-function.
My problem is that I just cant make it work. I tried varios codes, but none worked.
This is what Xara Generates (navigation-bar):
HTML Code:
<a onclick="return(xr_nn());" target="_self" href="#Link_To_Anchor">
<img style="left: 488px; top: 496px; width: 220px; height: 40px;" onmousemove="xr_mo(this,0,event)" title="" alt="" src="index_html_files/25213.png" class="xr_ap">
<!-- MORE MOUSEOVER IMAGES-->
</a>
And this is the jquery Javascript I tried to call a tracking function (NOT WORKING)
Code:
<script>
function trackTheClick(e) {
var link = e.attr('href');
if ( link.indexOf("#") !== -1 ) {
_paq.push(['trackPageView', link]);
}
}
$(document).ready(function() {
$('a').click( function() {
trackTheClick($(this));
} );
});
</script>
Does anyone have an idea on how to do this?
Kind regards
Mike
Bookmarks