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!