Skip to content

Instantly share code, notes, and snippets.

@stephengodbold
Created July 1, 2014 07:57
Show Gist options
  • Save stephengodbold/99ab2a418a2961e6cc1e to your computer and use it in GitHub Desktop.
Save stephengodbold/99ab2a418a2961e6cc1e to your computer and use it in GitHub Desktop.
A TFS Web Extension to load Google Analytics into the page, and log a simple page view event
<WebAccess version="12.0">
<plugin name="Google Analytics for TFS" vendor="Steve Godbold" moreinfo="http://stevegodbold.com/" version="12.0.0.0" >
<modules >
<module namespace="SteveGodbold.TFS.Analytics" loadAfter="TFS.OM"/>
</modules>
</plugin>
</WebAccess>
TFS.module("SteveGodbold.TFS.Analytics", [], function(){
function resolveAnalyticsId() {
var currentHost = window.location.hostname;
if (currentHost.indexOf('some-url') {
return 'UA-00000000-1';
}
return 'UA-00000000-2';
}
$.getScript("https://www.google-analytics.com/analytics.js", function() {
var analyticsId = resolveAnalyticsId();
ga('create', analyticsId, 'auto');
ga('send', 'pageview');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment