web2feel.com – Free wordpress themes – Tutorials – Tips and tricks

Free WordPress Themes for everybody

Categories

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

 <?php wp_footer(); ?>

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.

<?php function add_google_analytics() { ?>
	<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
	<script type="text/javascript">
	var pageTracker = _gat._getTracker("UA-XXXXX-X");
	pageTracker._trackPageview();
	</script>
<?php }
	add_action('wp_footer', 'add_google_analytics');
?>

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.

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

    I m using TemSkin theme.. Please guide..
  • Thanks for your help .Let me do it into my blog .
  • Thanks for sharing
    very useful tips
  • 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.
  • Pkr4win
    Hi, plese help me in this question..So, this piece of code where i have to paste? In footer.php or in fuctions.php?
  • The footer.php already has that line of code embedded into it; you can view the file from within your Wordpress admin panel:
  • jinsona
    You dont have to paste this anywhere . It is already there on the theme. The code you should use is the one below it.
  • what? is code
  • hi, what do you mean by changing the “UA-XXXXX-X” code into my own? can i just simply put any letters in there?
  • 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.
  • SPEEDbagal
    Thanks! it work like a charm :) now I have 2 tracking for web visit, StatPress & Google Analytics :)

    Cheers!
  • 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].
  • jinsona
    Yes, it works on all web2feel themes.
  • 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.

  • Insert the analytics code just before the closing body tag in the theme footer; this is indicated in your analytics account
blog comments powered by Disqus

Feature your theme here

kill the spill

Sponsors

  • Theme forest
  • Gator
  • Codebreaker
  • Your Ad Here
  • Your Ad Here

Recent Uploads

My brother is getting married tomo: 22nd Aug. Wishing him the best..

Contact Me

Your Name (required)

Your Email (required)

Subject

Your Message

4+1=?