Title: admin statistics
Last modified: February 25, 2024

---

# admin statistics

 *  Resolved [vtrn](https://wordpress.org/support/users/vtrn/)
 * (@vtrn)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/)
 * Hello, I want this plugin not to calculate admin statistics
   In php, we can put
   an “if” so that the analytics code is not loaded for the admin roleBut this plugin
   does not have this featureHow should I do this?

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17452770)
 * Thanks for reaching out [@vtrn](https://wordpress.org/support/users/vtrn/). You
   can disable the Site Kit admin toolbar feature by visiting your plugin settings(
   [_Site Kit > Settings > Plugin Settings > Display relevant stats in the Admin toolbar_](https://i.imgur.com/oaUxoFj.png)).
   This will remove the plugins admin bar feature for all users. Note that this 
   includes the Search Console stats, not specifically the Analytics stats. It doesn’t
   impact the standard Site Kit dashboard page, from your wp-admin panel.
 * We also have a filter to disable the admin toolbar if you prefer to programmatically
   disable the admin toolbar using various conditions, including role based conditions.
   You’ll find more details on this [here](https://github.com/google/site-kit-wp/issues/990).
   If you need any assistance with this, let me know.
 *  Thread Starter [vtrn](https://wordpress.org/support/users/vtrn/)
 * (@vtrn)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17452986)
 * Hi, I don’t mean admin tool bar! I want admin statistics not to be counted
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17453177)
 * Apologies for the confusion, and great question. Site Kit by default won’t include
   logged in administrators for reporting in Google Analytics. You can change this
   setting at any stage via [Site Kit > Settings > Connected Services > Google Analytics > Exclude Analytics > All logged-in users](https://sitekit.withgoogle.com/wp-content/uploads/2023/09/image4-e1695919101435.png).
 * Let me know if you have any further questions with this.
 *  Thread Starter [vtrn](https://wordpress.org/support/users/vtrn/)
 * (@vtrn)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17454527)
 * Thank you, but I just want to exclude the statistics of the admin role!
 * Is there no way?
 * For example, the command to the function that inserts the code
 *  Thread Starter [vtrn](https://wordpress.org/support/users/vtrn/)
 * (@vtrn)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17454539)
 * `if ( !current_user_can( 'administrator' ) ) { G code }`
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17456000)
 * Thanks for the update. If you do not want to place the Analytics snippet for 
   only administrators roles, you can use a `googlesitekit_analytics-4_tag_blocked`
   filter, with modifications that apply to administrator roles only below.
 *     ```wp-block-code
       add_filter( 'googlesitekit_analytics-4_tag_blocked', 'restrict_analytics_snippet' );
       function restrict_analytics_snippet( $original ){
        // don't place GA snippet for admins
         if (current_user_can( 'manage_options' ) )
         return true;
       }  
       ```
   
 * What the above will do, is not place the Site Kit code snippet (for Google analytics)
   for administrator roles only. It uses an administrator only capability (manage_options).
 * Let me know if that answers your query, or ask if you have any questions. Note
   that to apply the above, please use a child theme, or a custom functions plugin,
   as opposed to your themes functions.php file, which will get overwritten on each
   theme update.
 *  Thread Starter [vtrn](https://wordpress.org/support/users/vtrn/)
 * (@vtrn)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17469287)
 * Hi, it worked, but there was a problem with your code
   You did not write { } for
   condition!Final code:
 *     ```wp-block-code
       add_filter( 'googlesitekit_analytics-4_tag_blocked', 'restrict_analytics_snippet' );
       function restrict_analytics_snippet( $original ) {
       if (current_user_can( 'manage_options' ) ) {
       return true;
       }
       }
       ```
   
 * But I have a question, don’t we need to return the initial value after this condition?
 * like:
 *     ```wp-block-code
       add_filter( 'googlesitekit_analytics-4_tag_blocked', 'restrict_analytics_snippet' );
       function restrict_analytics_snippet( $original ) {
       if ( current_user_can( 'manage_options' ) ) {
       return true;
       }
       return $original; or return true; ?
       }
       ```
   
    -  This reply was modified 2 years, 4 months ago by [vtrn](https://wordpress.org/support/users/vtrn/).
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17471523)
 * Glad to hear that [@vtrn](https://wordpress.org/support/users/vtrn/)
 * > But I have a question, don’t we need to return the initial value after this
   > condition?
 * The original value of false will remain if the condition isn’t met. But you can
   add `return false` outside of the condition if you wish.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘admin statistics’ is closed to new replies.

 * ![](https://ps.w.org/google-site-kit/assets/icon-256x256.png?rev=3141863)
 * [Site Kit by Google - Analytics, Search Console, AdSense, Speed](https://wordpress.org/plugins/google-site-kit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-site-kit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-site-kit/)
 * [Active Topics](https://wordpress.org/support/plugin/google-site-kit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-site-kit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-site-kit/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/admin-statistics/#post-17471523)
 * Status: resolved