Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benbalter/902140 to your computer and use it in GitHub Desktop.
Save benbalter/902140 to your computer and use it in GitHub Desktop.
Conditionally load Google Analytics Tracking Code
//Conditionally load Google Analytics tracking code
//GA code optimized by Html5boiler plate -- https://github.com/paulirish/html5-boilerplate
if ( !window._gat || !window._gat._getTracker ) {
var _gaq=[["_setAccount","UA-XXX-1"],["_trackPageview"]];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));
}
@mlincoln
Copy link

I tried to use this replacing the condition with the role of my users:
if ($.inArray('student',ENV['current_user_roles']) === 1 ) { ...
But it seems to track everyone, regardless of whether they are of the role student or not. Any advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment