Return to Snippet

Revision: 40685
at April 21, 2011 06:52 by rgsmith007


Updated Code
<script type="text/javascript">
  $(document).ready(function() {
	$('body a').filter(function() {
		var theHref = this;
 
		if (theHref.hostname && theHref.hostname !== location.hostname) {
			$(theHref).not(".noAutoLink").attr('target', '_blank').bind('click keypress', function(event) {
				var code = event.charCode || event.keyCode;
 
				if (!code || (code && code == 13)) {
                                        var fixedLink = this.href;
                                        var _gaq = _gaq || [];
                        
                                        fixedLink = fixedLink.replace(/https?:\/\/(.*)/, "$1");
                                        fixedLink = '/outgoing/' + fixedLink;

                                        _gaq.push(['_trackPageview', fixedLink]);
				};
			});
		};
	});
  });
</script>

Revision: 40684
at February 5, 2011 03:13 by rgsmith007


Updated Code
<script type="text/javascript">
  $(document).ready(function() {
	$('body a').filter(function() {
		var theHref = this;
 
		if (theHref.hostname && theHref.hostname !== location.hostname) {
			$(theHref).not(".noAutoLink").attr('target', '_blank').bind('click keypress', function(event) {
				var code = event.charCode || event.keyCode;
 
				if (!code || (code && code == 13)) {
                                        var fixedLink = this.href;
                                        var _gaq = _gaq || [];
                        
                                        fixedLink = fixedLink.replace(/https?:\/\/(.*)/, "$1");
                                        fixedLink = '/outgoing/' + fixedLink;

                                        _gaq.push(['_setAccount', 'UA-XXXXX-X']);
                                        _gaq.push(['_trackPageview', fixedLink]);
				};
			});
		};
	});
  });
</script>

Revision: 40683
at February 5, 2011 03:11 by rgsmith007


Initial Code
<script type="text/javascript">
  $(document).ready(function() {
	$('body a').filter(function() {
		var theHref = this;
 
		if (theHref.hostname && theHref.hostname !== location.hostname) {
			$(theHref).not(".noAutoLink").attr('target', '_blank').bind('click keypress', function(event) {
				var code = event.charCode || event.keyCode;
 
				if (!code || (code && code == 13)) {
                    var fixedLink = this.href;
                    var _gaq = _gaq || [];
                        
                    fixedLink = fixedLink.replace(/https?:\/\/(.*)/, "$1");
                    fixedLink = '/outgoing/' + fixedLink;

                    _gaq.push(['_setAccount', 'UA-XXXXX-X']);
                    _gaq.push(['_trackPageview', fixedLink]);
				};
			});
		};
	});
  });
</script>

Initial URL


Initial Description


Initial Title
Auto-tag Outbound Links for Google Analytics, Async Version

Initial Tags
link, google

Initial Language
jQuery