Add Google Analytics to my Blog

There are a few ways that you can add Google Analytics to your blog, but the best way to do it is using the settings interface on blogger.com.

This is because whenever you customize a template, your template becomes a fork of the template that you customized, at the time you customize it. So if Blogger roll out a new feature or a bugfix which is placed in the templates, you won't get it on your template because your template is customized. So, when possible, use the facilities built in to the template engine!

Note: The Google Analytics snippet added by default when you set up your Analytics ID in Blogger is namespaced to 'blogger'.  This means that any custom calls to log events either need to be set up in the default/empty namespace, or share the blogger namespace.

Get your Analytics ID

If you head to analytics.google.com, you should be able to create a new property which will have a tracker ID associated with it. Create the property for your blog's url, e.g. myblog.blogspot.com.

Grab the tracker ID (which looks something like UA-99999999-9) and copy it to your clipboard.

Apply the ID to your Blog

Back on blogger.com, head to Settings => Other, and paste the ID. Save!

This will result in your blog rendering the required Google Analytics snippet as part of the default template, meaning that new features should still get applied to your template.

Happy Blogging!

Comments

Popular posts from this blog

Remove the header image for posts in Emporio

Rotate my Blogger images

Add snippets to the Emporio theme