Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

How can I add Google Analytics to my web site?

I keep hearing from you and others that I really need to be tracking how people use my Web site and that I should be collecting "aggregate traffic statistics" and such. I've heard that Google Analytics is good - and the price, free, is great - but I'm not really clear how to use it and add it to my site. Can you please step me through the process, Dave? Thanks!


Dave's Answer:

You have received good advice! Regardless of the level of complexity of your Web site, whether it's a huge blog with thousands of articles - as mine is - or a five page brochureware billboard for your service business, it's critically important and darn useful to be able to know how many people are visiting your site, from where, how, and what they do once they're on the site.

As a simple example, let's say that you offer three different services through your company and you have three pages on your little Web site that highlights those, one per page. Which gets more traffic? What can you conclude about the appeal of your business based on that? Which of those converts into the potential customer picking up the phone and calling you or clicking on "contact us" and emailing in a query? Without feedback you're in the dark. With feedback you can continually refine your pages and your business both, growing smart and effective.

Google Analytics is a bit tricky to set up too, so I'm not surprised you've a bit of trepidation about doing so. It involves copying and pasting some pretty complicated code. The good news, though, is that you don't need to understand the HTML and JavaScript you cut and paste, you just need to not mess it up!

Start by going to Google Analytics and either signing up for a new account or signing in to your Google account. The button you seek is this:

google analytics

Once you've signed up you'll see an overview page which won't be very exciting since you don't have any collected data as of yet. On the right you'll see this, however:

google analytics overview detail

Click on the "+ Add new profile" link and you'll be able to specify the URL of your site:

google analytics create website profile

Here you can see that I'm actually stepping through the process of adding the analytics code to my film blog, Dave On Film.

Confusingly, the system then gives you an error message that there's no data to show:

google analytics tracking code status

Well, duh, there's no data because we just set up this account. You'd think Google would be a bit smarter about this step of the process!

Scroll down a bit on this page and you'll see the following:

google analytics tracking code

All you need to do now is basically copy and paste the complicated-looking HTML code that's in the box. Click anywhere in the box, which should select all of the content. Now type Ctrl-C, or Cmd-C or choose File --> Copy (depending on PC or Mac).

Open up another browser window or a new tab and get to the source code for your own Web pages. If you have a blog, you're in luck: just open up the appropriate template or templates so you can access the skeletal contents of the site.

Move to the bottom of the source page and before any sort of </body> or </html> simply paste the block of code from Google Analytics.

Save the new pages, rebuild your blog if appropriate. If you have a site where you're managing the pages manually, then you want to paste the analytics code onto every single page you'd like it to track and analyze for you. If you skip some, it won't know about them and your reporting data could be skewed.

Now that you're done adding the code, refresh the page on Google Analytics and instead of getting the earlier error, you should see this:

google analytics tracking code verified

Great. Now it's just a matter of sitting back and relaxing, waiting for some traffic to show up so you'll have analytic data. In the meantime, this is what it'll look like:

google analytics no visits

Remember that unlike many other services, Google Analytics is not real time, so if you reload a page, don't expect to instantly see that traffic reflected in your reports. Generally I find that analytics is about 12 hours behind.

Now your challenge is to drive traffic to your site and to remember to at least occasionally go and look at the Google Analytics data!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

I'm glad this came up because I have a couple of follow-up questions (I already have Analytics on my company's 1-year "new" website):
1. How often should one look at Google Analytics reports?
2. I know how to READ the reports; i.e. I can regurgitate the information in them to my supervisors, but what do I DO after that? i.e. How does one really sort through and INTERPRET the really IMPORTANT stuff because it seems to me - and I'm pretty web-savvy - that GA almost contains TOO much info.
Thanks!

Posted by: stlfarr at June 1, 2009 11:53 AM

Thanks for the tip, Dave. That made it easy. I'll try it out.

Posted by: Eric Savage at June 11, 2009 9:59 PM

You can actually change the date range in the URL so that the current day's data is included in some (maybe all) of the analytics reports.

Sitemeter is good for instant gratification.

Posted by: Kosmo @ The Casual Observer at June 17, 2009 3:10 PM

Thank you. I'm going to try this.

Posted by: Val Reimer at October 23, 2009 10:37 PM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.