BlogSynthesis

  • Home
  • Tutorials
  • Contact

How to Track WordPress Login, Register and Dashboard Activity with Google Analytics

February 16, 2014 by Anand Kumar 3 Comments

If you have a multi-author blog or a forum or some membership site based on WordPress. Then, you might like to add Google Analytics to WordPress Login, Register or even dashboard. It will help you to understand better about your users’ requirement and help you to how they are using your site.

Google Analytics on WordPress

Another good thing about this article is there is no need of any plugin. And we can easily add Google Analytics to WordPress Login and Register pages or even WordPress Dashboard. Now proceed to next.

If you are using a site specific plugin then add the following code to the plugin else add these codes to your active theme (or child theme) functions file. If you are absolute beginner then you may locate these files here.

Go to WordPress Dashboard –> Appearance –> Editor –> Theme Functions (functions.php)

Add Google Analytics code to WordPress login and register page

This is really easy, simply copy the following code and replace the line <!-- Your Analytics Code Here --> with your actual Google analytics tracking code.

add_action( 'login_head', 'synt_ga_login_page');
function synt_ga_login_page() { ?>
    <!-- Your Analytics Code Here -->
<?php }

This will add your analytics code to WordPress login, register and forget password page.

Track WordPress Dashboard with Google Analytics

Also, If you want to track WordPress Dashboard activities then add the following code.

add_action( 'admin_head', 'synth_admin_head_script' );
function synth_admin_head_script() {
  if ( !is_super_admin() || !is_admin() ) { ?>
    <!-- Your Analytics Code Here -->
 <?php } }

As you see, there is a if condition in the code snippet. If will filter super admins and admin of your WordPress. You may also customize users based on their roles and capabilities.

If you are going to make any change in the above code (other than adding google analytics code) then test your code on a test server. Otherwise, it may potentially break your site.

If you have any problem or have any suggestion leave a comment below. If you liked this article, please share with your friends.

Filed Under: Tutorials Tagged With: Analytics, Google+, Intermediate Tuts, WP Dashboard

Comments

  1. heer patel says

    May 29, 2014 at 3:40 am

    it is helpful to my dashboard also
    thank you

    Reply
  2. nev says

    June 17, 2014 at 8:06 am

    It would be better to register and enqueue the scripts properly, rather than include them in a function.

    Reply
  3. Julie says

    November 25, 2014 at 3:30 pm

    If I am using Google Tag Manager – how can I insert the GTM code into the body of the wp-login.php file? I’ve tried your code above but it insert it into the head tag. Any help would be appreciated!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Add NGINX as NodeBB Proxy Server
  • Install NodeBB on DigitalOcean Cloud In 5 minutes
  • The right way to customize WordPress Themes!
  • How to make WordPress Print Friendly
  • How to install WordPress on Localhost

Write for us · Contact · Privacy Policy
© Copyright 2012 BlogSynthesis · All Rights Reserved · Powered by Genesis Framework · WordPress · DigitalOcean