Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Which is the best approach to automatically add the _link GA action to every outbound link that points to a certain domain?


<a href="" onclick="_gaq.push(['_link', '']); return false;">See my blog</a>
share|improve this question
How would you normally add an onclick event handler? – w3d May 15 '13 at 7:41

1 Answer 1

up vote 2 down vote accepted

You can add an event handler to all links that point to a specific domain.

For example if the domain you are linking to is and jQuery 1.0+:

var linksToHost = $('a').filter(function(){

linksToHost.bind('click', function(event){
    _gaq.push(['_link', this.href]);

You must also enable linking on the target site in order for link to work properly: _gaq.push(['_setAllowLinker', true]);

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.