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.
- kristen's blog
- 61309 reads
This is a featured content block that has been configured to show blog nodes with terms SEO or Drupal SEO by the author kristen. It shows random list of 20 results in the block and 30 results on the more page.
- Drupal Nofollow Link Sculpting
- Drupal SEO Reviews
- 503 HTTP Status Code when Site Down
- Drupal Meta Tags (nodewords) Module for SEO
- Drupal Node Teaser SEO
- Drupal Has Multiple h1 Tags
- Kristen
- BADCamp Drupal SEO Presentation 2009
- HTML Validation: Free HTML Validator Tools
- Drupal Pathauto URL Aliases Settings
- Fix Duplicate Content with Global Redirect Module
- Basic SEO Top 10
- Drupal SEO Modules
- Drupal Pathauto Module
- Make Drupal SEO Friendly
- Free SEO Tools
- Free Google Keyword Research Tool
Comments
My UA-xxxx-x code does not show up on the pages code
Kristen, if you are still there I would appreciate some help!
I have installed the ga module, and as admin user can go to the configuration page, where I have inserted the UA-xxxx-x code.
Nevertheless, my page code still doesn't show the code.
I have selected to place it in the header because I don´t use a footer. Could this be part of the problem?
Do you know of any imcompatibilities with other commonly used modules?
Thanks a lot!
A Drupal lover.
Header vs footer
I vaguely recall trying to put it in the header before and it not working and it *not* working, but am not 100% positive about that. It depends on the theme, but it should really work in either spot for any proper theme.
You can put it in the footer if you are using any contrib theme because the theme will print out $footer and it will end up there. It doesn't matter if you have anything else in the footer.
If you created your own theme, you really need to make sure to do:
print $footer;
print $closure;
in the correct spots or some modules will not work (e.g. admin_menu).
Good luck,
Kristen
Installation perfect but Google analytics doesn't see it
Hey, great tutorial!
I know this was written two years ago, but hey maybe you're still out there...so here goes:
Everything on my end checked out fine, but I'm still getting the little yellow yield sign specifying that the code isn't recognized on me site. Should I wait a while for it to recognize the code?
Lag time
I found that it took a little while to show up *and* I had to be logged out and not admin (uid=1) to see it.
Good luck!
Kristen
Followed the instructions
I think I got it finally I have just switched the site from Joomla to Drupal. Wondered if you could check the code as nothing is showing up on the google analytics page. my site It is just blank. I am just a bit stuck on "6) put *inc *info *install *js *module"
Thanks loads :-)
Files
Sorry that wasn't clear. If you untar the google_analytics module files, just put the directory under /sites/all/modules or wherever you are keeping them.
Kristen
Access Denied to Google Analytics Config Page
Hello --
I followed your steps completely and was up to the point where I needed to enter my Google Analytics code in the configuration page.
Unfortunately when I try to go to the configuration page, I get an Access denied-You are not authorized to access this page. I am the administrator of the page and verified my role.
Do you know what may be going on?
Many thanks for your help,
Elana
Permissions
If you are uid=1, then you shouldn't see this. But, if you had an "admin" role, and then installed the module, then you would see this error if you haven't turned on the permission "administer google analytics" for the admin role.
1) go to: admin/user/permissions
2) search for "administer google analytics"
3) check it for your admin role
If it is already checked, then perhaps there is a bug.
Good luck,
Kristen
can't get analytics to work.
I ftpd the module into the modules folder and have activated it but for some reason the module does not appear in administer/site configuration/ if I run a status report (reports/status report) I do see the a line for the googel analytics module with the following error "Google Analytics module has not been configured yet. Please configure its settings from the Google Analytics settings page.". When I click on the link i get an "Access denied
You are not authorized to access this page.". Now in your above instructions you state going to "admin/user/permissions" but I only have access to "administer/user management/user settings/" and nowhere within there can I see "administer google analytics" any thoughts?
User permissions
You will need to be user #1 (uid=1) or have administer users permission in order to go to the admin/user/permissions page and see the Google Analytics permissions. If you don't have access to the user #1 account, you will need to contact that person and ask them to give you permission to administer GA.
Good luck!
Kristen
Permission Tip - Thank you!
I ran into this same problem this morning. Thanks for the tip!
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: http://www.ubercart.org/forum/support/3638/uc_googleanalytics_doesnt_wor...
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-