Skip to Content

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.

ALL COMMENTS ARE MODERATED AND SPAM WILL BE DELETED SO SAVE YOUR TIME AND MINE AND ONLY LEAVE A COMMENT IF YOU ARE REALLY LEAVING A COMMENT AND NOT TRYING TO LINK OFF TO ANOTHER SITE FOR SOME GOOGLE LOVE.

Comments

Helpful

This article was very helpful while setting up google analytics on my site, thank you for taking the time to post the steps for us!

Katy
Steam Showers

druple and google ecommerce tracking with ubbercart

Hi there

I hope you can help

It appears that the google analytics is recording sales for people who dont finish the checkout process, and therefore the ecommerce figures are slighlty out? Druple - Google tracking with ubbercart also

do you know anyway to fix this,

Regards

Diane

Ubercart conversions

I don't know what module versions you are using but there appeared to be some problems with compatibility with the google analytics module and the ubercart module with legacy javascript usage. Here's a post about it with a possible fix. Good luck!

Am I doing something wrong?

Kristen,
I did everything up to this point...
"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 and entered in my code into the "account number" field."

But when I enabled the module, I don't get the config page. :(
I'm operating Drupal 6x, is it on a core page as an option.
helplessly lost on this...your help is much appreciated.

Thanks
Stefan

Google Analytics Settings Page

Hi Stefan,

Hopefully you already figured it out but, if not, the settings page is at admin/settings/googleanalytics. I'll update the article to be more clear. If you haven't already installed it, I recommend the Administration Menu module so that you have a quick menu on the top of the page for finding your settings pages; otherwise, these can be harder to find.

Good luck,
Kristen

New User Installed Google Analytics

Thanks for the great blog article. I am a new Drupal user & found this most helpful. Installed this in a matter of minutes & confirmed it is working. I will be back to visit again for more tips.

-Les-

Post new comment - ALL COMMENTS ARE MODERATED - SPAM WILL BE DELETED!

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Powered by Drupal, an open source content management system