So I am using Google analytics, I’ve installed the code via the admin area. Is there any way that the scripts don’t get loaded up if the admin user is logged in? Will the below code do the job or I have to use any other code?
If you can’t use those, you may be able to use some client-side scripts to query the Admin API to detect if an admin session cookie exists and only inject the script when there’s no session but it’s not optimal, it will slow down the script insertion and it’s not foolproof due to browser’s privacy mechanisms blocking cross-site request cookies. There’s some old discussion for how to do that in this topic: