Saturday, May 19, 2012

google Analytics to wordpress Theme footer

Posted by admin On April - 20 - 2010

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(); ?>

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” ></script>

<script >

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.

Popularity: 2% [?]

Leave a Reply

improve your SEO potential

For most people the upcoming holiday season will be one for relaxing and spending quality time with the family. But, [...]

Open source CMS

nomey
Cross-platform
Anomey is a small but effective framework and CMS for developing and maintaining web sites. (GPL)
BIGACE
Cross-platform
BIGACE is a multi-site, multi-language and [...]

Web Development / Frameworks

Bitweaver
Cross-platform
Bitweaver is a free and open source web application framework and content management system. (LGPL)
CakePHP
Cross-platform
CakePHP is a rapid development framework for [...]

Web Development Utilities

CKeditor
Cross-platform
This HTML text editor brings to the web much of the power of desktop editors like MS Word. It’s lightweight [...]

TAG CLOUD


Fatal error: Call to undefined function get_theme_option() in /home/sitescod/public_html/wp-content/themes/chronicle/footer.php on line 14