How to Setup Google Analytics

<?php if ( is_user_logged_in() ) { ?>

<!--the analytics code is hidden because you are logged in-->

<?php } else { ?>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'xx', 'auto');
  ga('send', 'pageview');

</script>

<?php } ?>

The first step to setting up a Google Analytics Account to first setup a Gmail account for the client (IF you or the client has not already done so).
Once the Gmail account has been created, you want to go to www.google.com/analytics/ and register using the account you just made or the existing Gmail account that the client would like to use.
After registration, you will be sent to a screen that displays your UA code or Tracking Code. Copy and paste that code to a text editor because you will need that in a minute.

Now go Install the Google Analytics Plugin to WordPress and activate it. Once you activate it, you will need to navigate to the Settings menu for the Google Analytics Plugin and enable the following settings:

  1. Manually enter the UA Code. This is were you enter that UA code that you had copied and pasted in the previous steps
  2. Advanced Settings
  3. Logged in users under the Custom Variables menu
  4. The above settings will look like this:
    Capture
  5. Finally change the ignore users drop-down selection, under Advanced Settings, to Editor.
    googleAnalyticsScreenshot2

Click the Update Settings button and then click the Allow Tracking button when the notification pops up.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.