Skip to content

Instantly share code, notes, and snippets.

  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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