diff --git a/advanced_examples_index.html b/advanced_examples_index.html index dc72b71..642c2d1 100644 --- a/advanced_examples_index.html +++ b/advanced_examples_index.html @@ -75,6 +75,21 @@ var pageTracker = _gat._getTracker("UA-41100937-1"); pageTracker._trackPageview(); } catch(err) {} + $(function() { + $("a").on('click',function(e){ + var url = $(this).attr("href"); + if (e.currentTarget.host != window.location.host) { + _gat._getTrackerByName()._trackEvent("Outbound Links", e.currentTarget.host.replace(':80',''), url, 0); + if (e.metaKey || e.ctrlKey) { + var newtab = true; + } + if (!newtab) { + e.preventDefault(); + setTimeout('document.location = "' + url + '"', 100); + } + } + }); + }); \ No newline at end of file diff --git a/advanced_examples_viewer.html b/advanced_examples_viewer.html index 18b0361..d00e9cf 100644 --- a/advanced_examples_viewer.html +++ b/advanced_examples_viewer.html @@ -115,6 +115,21 @@ var pageTracker = _gat._getTracker("UA-41100937-1"); pageTracker._trackPageview(); } catch(err) {} + $(function() { + $("a").on('click',function(e){ + var url = $(this).attr("href"); + if (e.currentTarget.host != window.location.host) { + _gat._getTrackerByName()._trackEvent("Outbound Links", e.currentTarget.host.replace(':80',''), url, 0); + if (e.metaKey || e.ctrlKey) { + var newtab = true; + } + if (!newtab) { + e.preventDefault(); + setTimeout('document.location = "' + url + '"', 100); + } + } + }); + }); \ No newline at end of file diff --git a/examples_viewer.html b/examples_viewer.html index eaed281..1f25b73 100644 --- a/examples_viewer.html +++ b/examples_viewer.html @@ -115,6 +115,21 @@ var pageTracker = _gat._getTracker("UA-41100937-1"); pageTracker._trackPageview(); } catch(err) {} + $(function() { + $("a").on('click',function(e){ + var url = $(this).attr("href"); + if (e.currentTarget.host != window.location.host) { + _gat._getTrackerByName()._trackEvent("Outbound Links", e.currentTarget.host.replace(':80',''), url, 0); + if (e.metaKey || e.ctrlKey) { + var newtab = true; + } + if (!newtab) { + e.preventDefault(); + setTimeout('document.location = "' + url + '"', 100); + } + } + }); + }); Fork me on GitHub