How to Add Google Analytics to Wordpress

Here are the steps to adding your Google Analytics code to  your Wordpress blog.

1. Grab and copy your Google Analytics code.  The code will look something like this

<script type=“text/javascript”>
var gaJsHost = ((”https:” == document.location.protocol) ? “https://ssl.” : “http://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(”UA-1234567-89″);
pageTracker._trackPageview();
} catch(err) {}</script><!–End Footer–>

2.  Paste this code in footer.php of your Wordpress theme file.

There are a few ways to do this.

One way is to do this through your dashboard.  For this to work your footer.php theme files must have chmod 777 permission (full read, write, execute permission).  If you won’t be able to modify your theme file.

Login to your dashboard and click on “Editor’ link under Appearance metabox:

appearance-metabox

Then click on “footer.php” and paste your Google Analytics code right before the </body> tag.

The other way is to use a FTP program to transfer footer.php file to your local hard driver, paste the Analytics code in footer.php right before the </body> tag, and upload and overwrite the file on the server.

Your footer.php, along with other theme files should be located in this path:

/public_html/wp-contents/themes/[name of theme]

If you don’t have FTP nor can you modify footer.php via the Dashboard, your last resort would be to login to cPanel of your hosting account, and use the File Manager utility to modify footer.php to include your Google Analytics code.

The reason why you should put your Analytics code in footer.php is simple – footer.php gets included in all pages and posts of your blog so putting your Analytics code there ensures all traffic information is captured.

You must be logged in to post a comment.

line
Powered by Wordpress | Designed by Elegant-Themes