Tracking Statistics with Google Analytics

Admin Mon, 07/21/2008 - 15:20 1 Comment

I love to know who's visiting my site, where from, and what they are looking at. Its interesting information in and of itself but it also helps greatly when adding advertisements to your site. Another thing I like to look at is how many people are using FireFox versus that other internet browser

Google has a great free service called Google Analytics. All you have to do is sign up for the service and then you can have a fairly high quality visitor tracking service. Here's how you get your Drupal site set up with Google Analytics.

First head over to the Google Analytics site. If you use any of Google's other services simply login with your username and password. If you don't have one simply sign up for google analyitcs. Once you have done that you should see a screen like this:

Google Analytics Screen 1

From here you simply add your sites URL information give it a name (this will be used later by you to keep your sites straight if you have a bunch of them). Then you add your Contact Info and accept the Google terms - make sure you read them all first :).

Now you will see a screen that has a text box with a bunch of javascript and HTML code. Normally you would add this code to every page on your website by hand. However, with Drupal of course theres an easier way. The main thing you need to know is what your tracking code is. This code is on the line that starts with "var pageTracker = ...". It is the code that looks like: UA-1234567-8. Look at this picture to see it.

Google Analytics Screen 2

OK write that code down and keep ahold of it. You will be using it shortly.

To get Google Analytics working with Drupal all you need to do is install the Google Analytics module. This module will take care of all the messy work for you. You can download the Drupal module here. Download this module and install it. If you don't know how, I have a tutorial that teaches you how to install a Drupal module the correct way.

Once you have the Drupal module installed navigate to Administer -> Site Configuration -> Google Analytics. On this screen you will see the first box asks you to enter your Google Analytics account number. This is where you enter your UA-1234567-8 number. You can play around with the other settings if you wish but the default values are great for most sites.

Once you've entered your account number save your settings and head back over the Google's site. Now it should tell you that Tracking is installed. Wait a little while and you will start seeing information showing up in the Google tracking info.

Note: By default Google only shows you information for past days not the current one. You can selelct the current day in their date drop down in the upper left of the screen. Also their tracking isn't in real time its more in batches so you might have to wait a few hours (or even a day) before your data shows up.

Now have fun. You can see how many people came to your site, where they came from, what they were searching for, even what country they live in.

Comments:

Posted by Anonymous (not verified) on Tue, 11/11/2008 - 03:54

Hi,
This is very helpful however, I keep getting an 'invalid input' error message every time I enter the domain name. I've tried getting rid of all the 'invalid' characters but still get this message and fail to progress.
Can you help?
Thanks!

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options