Wordpress and Google Analytics: how to avoid administrative area count?

Asked

Viewed 93 times

0

How to set up Google Analytics Code to prevent administrators' or authors' access to Wordpress administrative areas from being counted?

  • how did you install the code? Using a plugin? Pasting the script into the pages?

  • I use a plugin

  • Your plugin should have an admin page where you select whether or not to track the admin pages/actions. No more details is all I can tell you.

  • But my intention is to do this in javascript code. Because then, I am not in the plugin dependency.

2 answers

0

If you want to do it in hand, here it goes:

  1. Install the plugin https://br.wordpress.org/plugins/header-footer/

  2. Enter in the Footer tab:

    <? if (!is_user_logged_in()) { ?>
    <script type="text/javascript">
    ...GOOGLE ANALYTICS CODE...
    <? } ?>
    
  • Leonel, to understand: the command <? (!is_user_logged_in()) { ? > is a php that denies reading Google-Analytics if the "user" is logged in to the admin panel. That’s it?

  • Exact @Edmarrobertoprandini!

  • Just so you know, your suggestion didn’t work.

  • You still need a hand with that? Try to validate whether or not you are calling with the Chrome extension: https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna

  • Actually, I partially solved it by creating a filter for /wp-admin/ in the GA administration. But, pages visited by administrators outside of wp-admin will be logged, which I intended would not be calculated.

  • You can add the Google tag by your footer.php: <? php if ( !is_user_logged_in()) { ? > <script type="text/javascript"> GA code </script> <?php } ? > Reference: https://www.doitwithwp.com/exclude-admins-from-google-analytics-on-wordpress/

Show 1 more comment

0

Most likely the plugin you use already has this option. I use Yoast SEO, considered one of the best on the market, and it already has this option to prevent count of administrators.

  • Where? How to configure?

  • Which plugin do you use? I just wanted to make a correction that Yoast Analytics became Monster Insights Analytics. To edit you access the menu in the left sidebar in this sequence. Insights > Settings > Tracking > Ignore These user roles from tracking: Here you can add positions you don’t want to be counted. Using Monster Insights Analytics, old Yoast Analytics.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.