Install Google Analytics in Wordpress

by John H
2 minutes

If you want to install your Wordpress script so that it works regardless of the theme you install you will need to  paste your code into the general-template.php file in the wp-includes folder.  Here are the steps

1.  In your Wordpress installation go into wp-includes

1

  1. Edit general-template.php2

  2. Edit function get_footer() on line 53

at the bottom of the function (around line 68)  before the closing "}" put a  " ?>" . . . At that point paste in your Google analytics script (This is the script that you would get after registering your site at Google.com/analytics.  Paste The code then put "<?php" .  Save your file - Delete the cache of Wordpress and everything should be working.

3What we've done is install the Google Analytics script into the get-footer function.  That way anytime that function is called (i.e. the end of the wordpress template action) the analytics script will be drawn.  That will ensure that whatever template you are using the script will work - eliminating the need to put the script into any actual template code.

*This will only work if the template you are using calls the get-footer function.

** IF YOU UPGRADE WORDPRESS YOUR CODE WILL DISAPPEAR AND YOU WILL NEED TO REPEAT THIS PROCESS.  When you do an upgrade the Wordpress core files are replaced with the newest version of the CMS - this will remove any custom code you made.

 

Related Articles

Setup Google Analytics with Subdomain

By default all of the traffic that goes to any subdomain shows up as a root traffic.  What if you...

John H John H
~1 minute

Tracking button clicks with Google Analytics and JQuery

Using jquery it is  very easy to push clicks and events to Google analytics To make things...

John H John H
2 minutes

Scroller Animation Resources

Scroll activated website animations are so hot right now. Oh my gosh sooooo hot. Here are some...

John H John H
~1 minute