Drupal Google Analytics Setup

I just set up Google Analytics on Drupal for kristen.org and some other sites I’m working on. I have used awstats in the past but not Google Analytics but everyone was raving about it, so now I can see what’s the buzz.

First, I signed up with Google Analytics which is (of course) free. Also, you can set up several websites in your account as well as share accounts and create multiple accounts. Very handy.

I did make a mistake setting it up initially because someone had added me to their GA account already so I just added my websites when I was viewing that account. That meant that they could view the website statistics for the sites I added… oops! Fortunately, I realized the mistake pretty fast and didn’t really have any data yet.

So, to create my own account, I chose “Create New Account” in the upper right drop-down list and filled in the info for kristen.org. It gave me the javascript needed for the tracking, but I just grabbed the code out of it (UA-xxxxxxx-x).

I used the Drupal Google Analytics module by downloading the zip file and unzipping it and ftp’ing the files to GoDaddy in the correct location.

1) get Google Anaytics module and unzip
2) ftp -u xxx yyy.zzz
3) cd sites/all
4) mkdir modules (if not there already)
5) mkdir google_analytics
6) put *inc *info *install *js *module

After copying the code into place, I logged in as admin on my website and went to the Drupal modules page (/admin/build/modules) and turned on the Google Analytics module. Then, I went to the Drupal Google Analytics settings/configuration page (admin/settings/googleanalytics) and entered in my code into the “account number” field.

To make sure it was really working, I simply did a “view source” on a page that should be tracked (e.g. home page but not admin pages) and looked for the javascript (contains ga.js in it). Once I saw the javascript was there, I went back to my Google Analytics account page and clicked “Check Status” for the desired website. I could tell it was added correctly because it said “Tracking Installed” (or “Waiting for Data” if on the “Edit” page). It took a few hours before any data appeared.

Update – 1/2/09 – When configuring the Drupal Google Analytics module, it’s a good idea to include the user role in the tracking code or limit the roles tracked to Anonymous (unless you plan on having lots of registered users). Otherwise, your statistics will include admin views. You can also get better Drupal node count statistics by using the Advanced Statistics Settings module.

No related posts.