How to Setup Google Analytics on your WordPress Website Plugin Free

Posted OnNov 14, 2013     CategoryDevelopment, Plugins     CommentsNo comment

In this tutorial we’ll be teaching you how to setup your Google Analytics tracking code on your WordPress Website. To do this, you will need SFTP/SSH access to your server.

Step 1) Create a Child Theme, as directly modifying the original Theme’s files is never recommended.

Step 2) Duplicate the header.php file from the original theme, into the Child Theme’s folder.

Step 3) Insert the Google Analytics tracking code, as provided by Google, into the header.php, ideally before the closing </head> tag — it will look similar to the below.

<?php wp_head(); ?>
<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', 'UA-42516074-7', 'wpkb.com');
  ga('send', 'pageview');

</script>
</head>

This should complete the setup of your Google Analytics code on your WordPress website.

More Reading

  • How to Setup Bing Webmaster Tools on Your WordPress Site
  • How to Setup Google Webmaster Tools on your WordPress Website
  • Leave a Reply

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

    Send this to friend