Skip to content

Instantly share code, notes, and snippets.

@underdown
Created August 15, 2013 21:41
Show Gist options
  • Select an option

  • Save underdown/6245230 to your computer and use it in GitHub Desktop.

Select an option

Save underdown/6245230 to your computer and use it in GitHub Desktop.
cross domain link tracking - Google Analytics (cribbed from http://moz.com/ugc/google-analytics-cross-domain-tracking-made-easy-14596)
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
// Add onClick _link to all <a> elements on page where href contains example-A.com
$("a[href*='example-A.com']").click(function() {
_gaq.push(['_link', this.href]);
return false;
});
// Add onSubmit _linkByPost to all <form> elements on page where action contains example-A.com
$("form[action*='example-A.com']").attr("onSubmit","_gaq.push(['_linkByPost', this])");
});
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment