Lightweight GA (Google Analytics) on WordPress installation

Today was time to install Google Analytics onto this blog. As you can imagine, there is far more than a “handful” of WordPress plugins to enable something as simple as GA Tracking.

I wanted to go for something a little more lightweight. Let’s face it, a plugin is a little overkill for two reasons. First of all, without tearing down into the source code of each plugin, you really don’t know what all its doing in the background. And second of all,¬†Google gives you the Analytics code, so why make it harder than it has to be?

I vouched to instead edit my WordPress themes footer.php file, and add the Analytics tracking code provided by Google. By doing this, I eliminate the need to install possibly heavy or insecure plugins.

Simply drop the code from Google (example below) into the footer.php file (/wordpress_dir/wp-content/themes/theme-name/footer.php) anywhere before the </body> tag and Bob’s your uncle.

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-XXXXXXXX-X', 'auto');
  ga('send', 'pageview');


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.