Adding Google Analytics

I suddenly had the urge to know how many visitors my site is getting. I had added Google Analytics code manually to the other site, but didn’t have it on the main church site.

Logging in to Google Analytics and getting the code was easy, the problem was how to put it in. The instructions said to put it before the </head> tag, which implied putting the Javascript into a .js file and using wp_enqueue_script() to put it in. I decided to google a bit to see if this is the best way to insert the code.

Of course there are already plugins to do this. I decided to try the one by Joost ( The options are pretty comprehensive and it seems simple enough to use. I just had to type in the UA number and that’s it!

Now to wait and see if it starts tracking successfully.


2 thoughts on “Adding Google Analytics”

  1. I think it’s very cool what you are doing – documenting your trial and errors. Believe it or not, it will help you in more ways than you think, and will make a much better developer out of you in the long run, even if you’re doing it just for the hell of it.

    One note on the Google analytic code:

    Try not to use a plugin as it is unnecessary. Just insert the code in your footer.php before the tag. It will load on every page, and it will be the last thing to load. Being it the last script to run, it has the advantage that it will not slow down the site, and will track only the complete pages rather than tracking half loaded pages. So if someone landed on that page and closed it before it loaded, it will not track it, hence you get more accurate data.

    Also I use SEO ultimate plugin on virtually all my own and clients’ sites, and beside it being an awesome SEO tool, it has a feature called the code inserter, which you can use to put any kind of code anywhere you like without even opening a single php file.

    Good luck with your site and i would love to see the final result.


    Chris Sorbi

    1. Hi Chris,

      Thanks for your encouragement and suggestions. I used the plugin because it was the fastest thing to do, but if I do get the time, I’ll try out your suggestion.

      I’ve taken a look at your site too and I think your motorcycle trip is really awesome. Sounds like you’re having the time of your life. I’ll PM you the site URL, and hope you have a great time seeing the world on your motorcycle.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s