Wordpress: Add Google Analytics to Footer


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2.  * Add Google Analytics to Footer
  3.  * http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/
  4.  *
  5.  **/
  6. function myfunction_add_google_analytics() {
  7. echo '<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>';
  8. echo '<script type="text/javascript">';
  9. echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");';
  10. echo 'pageTracker._trackPageview();';
  11. echo '</script>';
  12. }
  13. add_action('wp_footer', 'myfunction_add_google_analytics');

URL: http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.