• This a little trick I discovered just a few minutes ago. I have been using WP.com stats plugin in my site for a while but suddenly the plug stopped working.

    So I installed GA in my site to keep track of it as I cannot relly on WP stats system as it failed updating. So I wanted to ommit logged in users from appearing in the GA stats and I think I found the way to do so, by using the same function/tag the comments template usera to differenciate from loggedin users of regular visitors:

    <?php if ( $user_ID ) : ?>
    <!-- you are logged in -->
    	<?php else : ?>
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "https://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("<blockquote>YOUR-GA-ACCOUNT-CODE-HERE</blockquote>");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    <?php endif; ?>

    I’m just gessing it works just fine, does anyone knows if this is true?
    does the GS stats depend on the script load?

    My tests indicate that the script absolutely does not load when a logged in user views a page in the site, on the other hand the GA script DOES load for regular users.

    Check it out! ??

    Note: as always, this code must be put before the ‘head’ section ends.

  • The topic ‘Google analytics logged in users ignore :)’ is closed to new replies.