Title: Block google analytics code for admin user
Last modified: February 14, 2021

---

# Block google analytics code for admin user

 *  Resolved [lencw](https://wordpress.org/support/users/lencw/)
 * (@lencw)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/block-google-analytics-code-for-admin-user/)
 * I have put the GA script in the non-necessary block, and it works with permissions
   on and off as expected. However, I have previously used a plugin for GA code 
   that has a switch to prevent GA code if the session is a logged-in admin user,
   so we are not logging their activity.
    The non-necessary block is JS only, is
   there a way to add the script if consent and if not an admin rights WordPress
   user?

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

 *  Plugin Author [WebToffee](https://wordpress.org/support/users/webtoffee/)
 * (@webtoffee)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/block-google-analytics-code-for-admin-user/#post-14063188)
 * Hi [@lencw](https://wordpress.org/support/users/lencw/),
 * Sorry to let you down, but there is no option to execute the scripts based on
   PHP condition check.
 *  Thread Starter [lencw](https://wordpress.org/support/users/lencw/)
 * (@lencw)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/block-google-analytics-code-for-admin-user/#post-14063655)
 * Thanks for confirming, would you consider this in future?
    For now I have added
   a filter in the GA view admin to filter out URLs for wp-admin and wp-login.php,
   but that does not remove tracking for a logged-in admin user looking at the front
   end of the website.

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

The topic ‘Block google analytics code for admin user’ is closed to new replies.

 * ![](https://ps.w.org/cookie-law-info/assets/icon.svg?rev=3007243)
 * [CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice)](https://wordpress.org/plugins/cookie-law-info/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-law-info/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-law-info/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-law-info/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-law-info/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-law-info/reviews/)

## Tags

 * [admin user](https://wordpress.org/support/topic-tag/admin-user/)

 * 2 replies
 * 2 participants
 * Last reply from: [lencw](https://wordpress.org/support/users/lencw/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/block-google-analytics-code-for-admin-user/#post-14063655)
 * Status: resolved