Posts: 808
Location: UK... where else?
|
Hi all, I am trying to add the Google Analytics external link tracker into some links on my site. The problem is, the links use javascript in two places and so no matter how I try to add the second script in it always fails. Can someone help me make sense of this?
The process is:
This is the desired output:
Code:
<a href="http://www.facebook.com/sharer.php?u=PAGEURL" onclick="javascript: pageTracker._trackPageview('share_link/PAGEURL');"><img src="facebook.png"></a>
Adding the first PAGEURL
This is how I currently display the links (without tracking)
Code:
<script language="JavaScript">
document.write( '<a href="http://www.facebook.com/sharer.php?u=' + location.href + '"><img src="facebook.png"></a>' );
</script>
Adding the second PAGEURL
This is my attempt at adding the second URL, I have tweaked the quote marks and apostrophes in loads of ways, but just can't make it work.
Code:
<script language="JavaScript">
document.write( '<a href="http://www.facebook.com/sharer.php?u=' + location.href + '" onclick="javascript: pageTracker._trackPageview('share_link/'+ location.href +'');"><imgsrc="facebook.png"></a>' );
</script>
Can anyone help?
|