• Thanks alot for that simple plugin. However I wanted to remove the analytics code when a user was logged into wordpress.

    I achieved this by replacing the lines 55-bottom from the current release (1.0.5) with this code:

    function add_analytics_code(){
      if (!is_user_logged_in()) {
       add_action('wp_head', 'googleanalytics');
     }
    }
    
    register_activation_hook(__FILE__, 'activate_googleanalytics');
    register_deactivation_hook(__FILE__, 'deactive_googleanalytics');
    
    if (is_admin()) {
      add_action('admin_init', 'admin_init_googleanalytics');
      add_action('admin_menu', 'admin_menu_googleanalytics');
    } else {
      add_action('init', 'add_analytics_code');
    }
    
    ?>

    Would be glad if this change could make it to the code base (maybe the more sophisticated developer might introduce a checkbox in the options dialog or so…).

    http://wordpress.org/plugins/googleanalytics/

Viewing 1 replies (of 1 total)
  • You could put the following in your functions.php if you wanted.

    remove_action( 'wp_head', 'googleanalytics');
    if (!is_admin() && !is_user_logged_in()) {
      add_action('wp_head', 'googleanalytics');
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Removed analytics code for logged in users’ is closed to new replies.