Google Analytics Tracking in WordPress Without a  Plugin

There are many plugins available that handle this, but sometimes a simple solution works best. For most of the WordPress sites I design I implement this basic Google Analytics function into functions.php to keep things lightweight and not dependent on plugins. The only extra feature added to Google Analytics is 404 error tracking, which I always add.

The base_google_analytics() Function


/**
*	Google analytics attached to footer
*/
function base_google_analytics() {
?>
	

I hope this helps you with your next project. As always, if you have any suggestions fire away!

Meet the Author

Kevin Leary, WordPress Consultant

I'm a freelance web developer and WordPress consultant in Boston, MA with 17 years of experience building websites and applications. View a portfolio of my work or request an estimate for your next project.