Created
April 4, 2011 18:34
-
-
Save benbalter/902140 to your computer and use it in GitHub Desktop.
Conditionally load Google Analytics Tracking Code
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
//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")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?