Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [textile] Javascript in links?
Sorry, I missed a few single quotes around 'http://'
when I posted. See revised code above.
Offline
#14 2008-10-02 18:58:17
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: [textile] Javascript in links?
Hate to say this but it’s still not picking up the external links.
Offline
Re: [textile] Javascript in links?
So this is where it ends without real access to the site…
Offline
#16 2008-10-02 21:20:15
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: [textile] Javascript in links?
Thanks for all the help Robert.
Offline
Offline
Re: [textile] Javascript in links?
This is what we came up with to add a new class to all links which do not point to the own site (www.example.com
in this case):
<script type="text/javascript">
$(document).ready( function() {
$("a[href^='http://']").each(function(){if($(this).attr('href').indexOf('http://www.example.com') == -1) $(this).addClass('external');})
$('a.external').click(function(){pageTracker._trackPageview(this.href);})
})
</script>
There’s certainly room for improvement, but it works as intended.
Offline
#19 2008-10-03 05:59:28
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: [textile] Javascript in links?
In case it’s not clear, the javascript added to the links is used by Google Analytics to track clicked outbound links.
More info here at Google
Offline