Disable Google Analytics by Role or User
Update: new code to allow excluding individual node as well as roles and users.
Google Analytics module allows for tracking by selected roles. What it does not natively provide is a mechanism to exclude specific roles.
To disable tracking for a particular role or even a specific user, edit Page specific tracking settings section. Choose Add if the following PHP code returns TRUE and enter the following code, adjusting the role names and the user IDs (uid). This could be also used for control of block displays, when displaying content to authenticated users but excluding a particular role.
<?php global ; // These are the roles who should not see this block = array('Administrator','Contributor','Forum admin'); = array(1,8); // Assume they can see it to start =TRUE; // Go through each role the user is in and, if we hit a role that is not allowed to see it, set valid to false foreach(->roles as ){ if(in_array(, )) { =FALSE; } } if(in_array(->uid, )) { =FALSE; } // If no roles were hit that aren't allowed, this will still be true. Otherwise it will be false. return ; ?>