How to add Google Analytics to WordPress theme footer without touching the footer file.

Every blogger in the blogosphere is aware of the Google’s tracking service , Google Analytics. It is an essential tool to monitor the site traffic details and performance statistics. Anybody can setup an analytics account for free with their Google account. Users will be a given a unique js tracking snippet, which can be inserted to the website. When it comes to WordPress blogs, there are numerous plugins available for enabling analytics tracking on the blog.

But here we are going to see how to add the analytics script to the site template, ideally to the footer using your functions.php file.
The process is very simple, and only requisite is that the footer file should have the

 

hook enabled. Obviously all themes on web2feel has this enabled.

To get started, you need to open the functions.php file in your theme on any text editor. Then add the following php snippet to it.

	<script src="http://www.google-analytics.com/ga.js" type="text/javascript"><!--mce:0--></script>
	<script type="text/javascript"><!--mce:1--></script>

Once added don’t forget to change the “UA-XXXXX-X” to your own unique tracking code.

# Remember : This process is template specific. If you added this to one template and later switch to another template, remember to add this script to its functions.php file also, to continue tracking.

  • zamangilani

    hi,
    how i can add this scarlet theme.because i dont scarlet theme footer has the requestie or not.

    please help me to add the google analytics to scarlet theme.

  • jinsona

    Yes, it works on all web2feel themes.

  • Adam

    hey jinsona.nice themes and spectacular designs.May i ask you to change the title of wordpress posts?Because you seem to have the same titles in all your posts [at least the very first four or five words].

  • Yes, it works on all web2feel themes.

  • SPEEDbagal

    Thanks! it work like a charm 🙂 now I have 2 tracking for web visit, StatPress & Google Analytics 🙂

    Cheers!

  • hi, what do you mean by changing the “UA-XXXXX-X” code into my own? can i just simply put any letters in there?

  • what? is code

  • Since 6 years of hardworking on online shoes trade, we have being enjoying good prestige with reasonable price, top quality, fashionable design & Timely Delivery by EMS, TNT, etc. So we win lots of regular customers from all over the world, especially from Western Europe (Italy, UK, France, Spain, & Germany etc), North America and Australia! Our professional exporting team will give you the best service to satisfy your request, and our skilled & experienced workers will strive to meet your needs.

  • Pkr4win

    Hi, plese help me in this question..So, this piece of code where i have to paste? <?php wp_footer(); ?> In footer.php or in fuctions.php?

  • jinsona

    You dont have to paste this anywhere <?php wp_footer(); ?> . It is already there on the theme. The code you should use is the one below it.

  • Ok, so you don't have to edit footer.php, but you DO have to edit the functions.php file; how is this helpful? Might as well just edit the footer.php, putting the analytics code just before the closing body tag as instructed through your analytics account.

  • Insert the analytics code just before the closing body tag in the theme footer; this is indicated in your analytics account

  • The footer.php already has that line of code embedded into it; you can view the file from within your WordPress admin panel:

  • Thanks for sharing
    very useful tips

  • Louis vuitton
  • you need to sign up to google analytics using gmail account (email with gmail will do fine). then add your site's url and google analytics will generate a unique code for you. UA-XXXXX-X is the format of that unique code – replace that with your own to see the tracking.

  • Thanks for your help .Let me do it into my blog .

  • Rajat Jain

    Hi.. i hav tried add GA code.. but my function.php just contain this..
    <?php
    require_once(TEMPLATEPATH . '/controlpanel.php');
    ?>

    I m using TemSkin theme.. Please guide..

  • How many stupid people have around the world. And all of them – know how to use the internet, keyboard, mouse but not their heads…

    • Oh, you are so right, my friend :)))) If they don’t know what they are doing as far as SEO for their WP site, then they need to go onto doing other things, and leave the rest to those who DO know what they are doing.

  • Jalicia

    I love this article. Very useful tips – tyfinc.com

  • short and useful.

  • It’s really good and cool 🙂

  • how to put it in blogger?

  • Your article is really helpful!

  • Thanks for the tutorial.That’s the clearest explanation of the process I have found.
    And, I’ve been searching on how to do this. Most instructions have not been as clear
    and as thorough.

  • Ahh, this makes things very easy to do insert google analytics. But I would prefer GA for WP… I’m scared of messing up codes, had a black history on it. 😀

  • I have created a bunch of word press blogs, I am willing to add this Google analytics to my blogs to keep track of number of visits and the keywords used for visiting the blog, Thanks for sharing the widget here,

  • It is what I’m looking for. I searched the simple and easy ways to add Google analytics for my wordpress blog. Thanks for sharing.

  • It eases me to add Google Analytic to my wordpress theme footer. Thanks for your tutorial.

  • vibram five fingers

    Do you like vibram five fingers shoes, now it is very popular and has many fans, if you like it, don’t wait but choose it. http://www.vibramfivefingersshoesusa.com/

  •  If they don’t know what they are doing as far as SEO for their WP site, then they need to go onto doing other things, and leave the rest to those who DO know what they are doing.

  •  If they don’t know what they are doing as far as SEO for their WP site, then they need to go onto doing other things, and leave the rest to those who DO know what they are doing.

  • AngryCoder

    This sucks balls!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • AngryCoder

    This sucks balls!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • AngryCoder

    This sucks balls!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • AngryCoder

    This sucks balls!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • This is not the right way to do it..

  • Great! Thanks, but will this work for self hosted twenty eleven theme as well?

    •  I am using the plugin method to add our WordPress blog with analytics.
      would you please tell me if I paste the code into the plugin where it
      goes to, means in footer or header. I am using the method mention in the
      below source,
      Google analytics for WordPress blog