Adding Google Analytics Tracking Code to WordPress

POSTED ON Aug 24, 2012

Joel Friedlander

Written by Joel Friedlander

Home > Blog > Self-Publishing, Social Media > Adding Google Analytics Tracking Code to WordPress

by Tracy R. Atkins (@TracyRAtkins)

I met Tracy in the comments on the blog, where he is a frequent contributor. Tracy has an extensive background in technology and is now on his way to becoming a self-published author. I asked him to lend his expertise to help authors trying to get a handle on the tasks they face as bloggers, and here’s his contribution:


Google Analytics is one of the most valuable tools you have to judge the effectiveness of your blog or website. Key performance indicators from the number of visitors to your site, the sources of that traffic and visitor behavior are available in a multitude of easy to read reports.

In only a few moments, you can research how effective an advertising campaign is for your book, what articles people read most and where the bulk of your readers reside. It is a fantastic tool and getting analytics data for your WordPress blog is very easy.

Google Analytics 1

Adding Google Analytics

Adding Google Analytics tracking to WordPress is a 2-part process.

  1. You must first acquire the analytics tracking code for your website by signing up for Google Analytics. Your personal tracking analytics code is a snippet of HTML/JAVA text, unique to your blog. When that text is read by an internet browser program, like Internet Explorer, Safari or Chrome, it sends website related tracking information about the website’s viewer to Google. That viewer data is then associated with your blog.
  2. The second piece of the process is to place your personal snippet of analytics code into a text box widget on your WordPress blog’s main menu. When in place, every visitor, to every page of your blog is tracked and the data is sent to Google Analytics. That’s all it takes to get analytics flowing!

The Tracking Code

Google Analytics 2

Upon completion of the sign-up process for Google Analytics, your website is assigned a unique Tracking ID and a Tracking Code snippet.

The Tracking ID is typically formatted as a string of alpha-numeric text.

Example: XX-########-#

The Tracking Code is a section of HTML that contains Java script computer code that tells your blog’s viewers’ browser to send some basic information to Google. It contains your unique Tracking ID. The script must be copied in its entirety and cannot be modified or changed in any way.

The code is typically several lines in length. It begins and ends with HTML SCRIPT tags.

Here’s an example:

Google Analytics 6

Copy this script by highlighting it, and use your keyboard or mouse copy function. You may also copy it to a word processor or notepad document for future use. You will later paste it to your WordPress blog’s text box for insertion to your blog.

Setting up Your Widget

Once you have the code in hand, you will need to log onto the administrator panel of your WordPress blog. In the dashboard, you must select “Appearance” from the menu and then “Widgets”.

Google Analytics 3

Next, drag a “Text Widget” from the widget selection area to the sidebar or footer area. Note, this text box will be invisible and the users of your blog will not see it.

Google Analytics 4

Insert the analytics tracking code into the text box. Typically, your analytics text box will be placed as the last item on the menu or footer list. Use the down arrow next to the text box widget you just inserted into the sidebar or footer box to expand it.

Leave the title box blank, so the text box does not show up on your sidebar or footer on the main website. In the text area, paste the code in into the box exactly as Google Analytics coded it. Then press “Save”.

Google Analytics 5

That’s it! You have successfully added analytics to your blog.

Since the sidebar or footer will appear on every page of your blog in most WordPress configurations, you will receive detailed tracking information from every visitor, for every page, automatically. You can now use Google Analytic’s powerful tools to track your WordPress blog’s visitors, while enjoying detailed reports on their behavior.

Tracy R. AtkinsTracy R. Atkins has been a technology aficionado since he was young. At the age of eighteen he played a critical role in an internet startup, cutting his tech-teeth during the dot-com boom. Throughout his career, he has earned numerous professional level tech-industry certifications, which he pursued out of a misguided sense of fun. Tracy is also the self-published author of Aeternum Ray.

Joel Friedlander

Written by
Joel Friedlander

Book Cover Design Checklist

Set your book up to SELL with our FREE Book Cover Design Checklist to boost the quality of your book to its very best!
Liked this post? Share it with friends!

More Helpful Articles