Created
July 1, 2014 07:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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