Share
ShareSidebar
2011-10-09 14:17:38 +0

Add Google Analytics to the footer - Wordpress

You should to replace the "UA-123456-1" with your actual GA code.

You may want to check out the three currently available Analytics options and modify the code accordingly. Currently, this function is using the newer “ga.js” tracking code, but that is easily changed to either of the other methods.

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

add_action
('wp_footer', 'add_google_analytics');

Rate this post

You must be registered to vote first

Other posts

Comments

Comment