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


	

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

Meet the Author

Kevin Leary, Boston WordPress Developer of 10 Years

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