Installing & Configuring the Google Analytics Module for Drupal 6.x

Posted Date: 
Thu, 03/26/2009

The Google Analytics module for Drupal 6.x integrates Drupal's powerful site administration tools so you can harness the fullest potential of your Google Analytics account.  The module offers user-specific, role-specific, and page-specific tracking.  It can send role or profile information to Google Analytics so you can run user segmentation reports.  You can easily extend your Google Analytics with custom JavaScript code.  The possibilities are endless!

What is Google Analytics? It is the next-generation web analytics tool that show you how people find your site, how people navigate through it, and how they become customers. Google Analytics is both easy to use and offers an enterprise-class reporting interface.  Google Analytics is also free!

Note: It's a high resolution video, so it plays well in full screen mode.

Primary Screencast: 


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks Brian for the detail

Thanks Brian for the detail explanation.

Thanks a lot.

Thanks Brian, good video. Iit's very clear.

this is the best explication

this is the best explication for drupal modules I have never seen in my life, I Wish all the modules on drupal have the same explication as you did for this module.


How to add tracking code

nice vid .. just wanted to ask you as to how to add the tracking code

Thanks Brian

That video actually made sense. I watched a how to video from my webhost that just confused me further, but your video allowed me to get this installed properly.

Google analytics

I'm building my site on my localhost first. If I install Google Analytics after I get everything moved to the server, will it work on the pre-existing nodes, or only on content created after it is installed?

Thank you to any one who might answer this!


thans for sharing this is really helpfull.........

Google analytics

I'm building my site on my localhost first. If I install Google Analytics after I get everything moved to the server, will it work on the pre-existing nodes, or only on content created after it is installed?

Thank you to any one who might answer this!


thanks - helpful

Very nice and very clear

First! thanks so much to you.great video very helpfull for me and all drupal developers.
once again thanks to you.

Very useful!

Thank you so much for making this video.
Even though i'm setting this module up for Drupal 7, the video can still be of great use.

I am not allergic to awesome

OK. I've seen a lot of screencasts over the last year. This is the first that made me genuinely LOL. Well done.

thanks, that was very useful

thanks, that was very useful

Very helpful, concise and

Very helpful, concise and clear. Many, many thanks.

Nice Job - I am new to drupal

Nice Job - I am new to drupal and this run through was just at the right level. Keep up the good work!

Google Analytics

I saw your screencast. I've installed the Google Analytics code (6.03x) into Drupal and completed configuration and permissions. I've doublechecked everything in Drupal and my Google Analytics account but Google has yet to display the 3 events that I activated in this module.

I waited the 48hrs. I am not sure why Google Analytics hasn't picked-up this information. I double checked that the correct Account Number was configured correctly in the module and all settings appear correct.

Any ideas? My site is

Any guidance you can provide is greatly appreciated.

Google Analytics

Thank you for your posting. I have Google Analytics installed in my site and I followed your Advanced Video for configuring to track events. Including tracking outgoing links, mail-to links and download links. For some reason I cannot see these Event Types in my Google Analytics account. Do I have to define these or will Google automatically recognize these events? This has been live for a few weeks now in Drupal, yet I don't see it reflected in Google Analytics.

Google Analytics Module 6.x 3.0

Google analytics module installed but scripot commented!

Dear Friends, I'have just installed the analytics module over Drupal 6.19. But when I verify the source code of the defaul site Ia get:

So, I do not know why this lines appear:

At the moment Google Analytics doesnt reach or receive any data form my site. Is there something to fix?

 what is the url of your

 what is the url of your site?

I saw your screencast

I saw your screencast recently after using the google analytics module for more than two years. It's a good screen cast for beginners.

However, I found the brief section on user permissions confusing when I saw the permissions "use php for tracking visibility" checked for all roles including anonymous users.

I had thought this permission was just to administer php permissions and have applied it only to developer and administrator roles successfully for years.

I also opened an issue in the module queue to confirm and clarify this, and want to let you know so you can contribute to the discussion.


NICE! one thing on 'Status: Tracking Unknown

After installing the module and setting up your google analytic account and are still getting the 'Status: Tracking Unknown', then go to:
Overview->Edit->Check Status
That should tell you if its installed correctly and if it is then it should start saying: 'Waiting for Data'


google analytics module

thank you very much for the video, it very helpfull :)

keep on sharing, brian,,..


PS: I started explore drupal at 2 weeks ago, and found your website, makes me more easier to modify drupal.

thanks for info

very useful one tnx for helping installing google analytics module and configuring it correctly

Google Analytics Header not showing up in Site Config Area

Hi Brian-

What if you're not able to see the Google Analytics header in the Site configuration area of Drupal? I installed the module in sites/all/modules like I do with my other modules and I also verified that it was installed in the administration by module page.

I've tried re-installing the module and clearing the Drupal cache.

Any tips you can offer? Thanks in advance.


it's probably a permissions issue

 Try checking your permissions for googleanalytics on this page: admin/user/permissions

Installing the module

why the module doesnt connect to the google analytic

Thanks but I made sure to

Thanks but I made sure to check that out before and I enabled all permissions for admins. Still not sure what's up.

So frustrating - anything else you can think of? Thanks so much for your help.

tracking still showing as not turned on

Great video Brian, thank you. I have followed the steps in the video. Cleared cache. Pasted <?php print $closure; ?> into my page.tpl.php file of my custom theme. cleared cache again. Still getting the tracking no installed.

When I created my Google Analytics account it gave me a code to paste into each page, I am taking for granted that this is being done through the Drupal module and do not need to paste this code anywhere. Is that correct?

Thank you so much for your help!

Error on Drupal 6.16

Good Evening,
First thank you for the module. Unfortunately i have just tried to install it on the fresh version on drupal 6.16 and i am having the following error :
warning: call_user_func_array() []: First argument is expected to be a valid callback, 'googleanalytics_admin_settings_form' was given in /nfs/c01/h12/mnt/9167/domains/ on line 372.\
I would like to mention i am just a beginner and it could be an stupid question but your help in understanding would be nice...


Hello, this error (to my

this error (to my knowledge) normally turns up if you change something in the menu or rename some functions in a module.

It can easily be fixed by a) clearning the cache b) rebuilding the menu tree

Try out a) above.



Thanks, it worked all well!

user config


First of all thank you the great video! It's awesome!

Bit i have a question! I've tried to setting google analytics in my page and it went well except one thing. I can't see the tracking option in the edit user menu. It would be important for me because there are three user who i don't want to track!

Thank you the help!

try looking here

Thanks dumi!  See if this works for you:

 under > "User specific tracking settings"
   select > "Track users by default, but let individual users to opt out."

 under > "Role specific tracking settings"
   Make sure that none are checked (everyone tracked) or you check the roles that matter to you.

  under > "Google Analytics configuration"
    check > "Enable user tracking"

Thank you the help! I think i

Thank you the help!

I think i misunderstood the meaning of the "Track users by default, but let individual users to opt out." Thanks for my not excellent english!

Thank you again!

What am I missing?

Ok, I would like to first make it clear that I am not allergic to awesomeness but I apparently am missing something here.

I performed the walkthrough just as the video explained it. Google Analytics however tells me that tracking code is not installed on my pages. Did I miss this part in the setup? My reading indicates that this module is supposed to take care of this after I entered the GA number.

Thanks for great video

Thanks for great video

it might be a cache issue

Go into this page:

There is a button near the bottom that reads, "Clear cached data".  Click it.
Have Google scan your site again and let me know the results.

Excellent! Followed along,

Excellent! Followed along, other than letting users opt out of tracking, and cleared the cache, did a ctrl + F5 on my google analytics page and sure enough it said Tracking Installed! Thanks!

Problem with Tracking not installed

I am new to Drupal and Analytics but have been tasked with sorting it out. I followed your excellent video and installed the google_analytics module. I left it wide open to grab all data. No segmentation or permissions monkey business for now. I just want a baseline. So following install, I checked back with Analytics and it was reporting that the tracker was not installed. I flushed cache under performance and still no change in status. Any ideas would be appreciated. Thanks in advance, Brian. Keep up the good work.


I think I know what's going on

I did a quick survey of your site ( and I think I know what going on.  The Google Analytics appears to be partially working.  First, I can see google analytics showing up in your jquery (around line 41 in your rendered html when doing view source).  The issue appears to be with your Drupal template.  If you could, check out your page.tpl.php file.  Near the very end of your php source code, there should be this ending:
    <?php print $closure; ?>
That "print $closure" is where the Google Analytics module puts the javascript.  If it's missing from your template, just put it in there, and clear your Drupal cache.  It should work just fine after that!

Thank you

Thanks for pointing out that template might not include closure!

I added <?php print $closure; ?> before body closing tag, cleared cache and google verified analytics code present with no probs!

Thanks again for great mod and support to your users!

Tracking Not Installed

I have this issue also.

If I view my page source it states that the code is there, I have checked my page.tpl.php file of my theme and the <?php print $closure; ?> is there but Google still says that the tracking code is not installed.

I have done a cahce clean also but still no go..

Strange thing is that in my GA account it is showing hits etc.. just don't know about this tracking code business.




That's very strange.  From my experience, GA doesn't show any hits unless it first detects the tracking code is installed.  How long have you been experiencing this issue?

GA Not Installed

I suppose from when I installed the module, about a week or more.



js - use google's copy instead of your local copy

I'm assuming this issue is affecting
This domain is using a local copy of the google javascript file.  Go into the GA module and tell it to not use a local copy, clear your theme cache, and have Google scan your site again.

Done that.


I have done as you suggested but still the same story.

I don't know whether I am reading too much into this as in my GA account overview I have the green tick, see here:-

but when I click on the edit profile button in account overview it shows:-

and then if I click on the check status link it shows:-

even though GA is showing me hits and various reports etc.. it is like it is not recognizing that the script is there, maybe this is a Google thing?



yep, it's a google thing

Yeah, get in touch with Google.  Usually if you click the Help link in the top right of Analytics, you go through a maze of troubleshooting prompts before you get to a form that lets you submit a ticket to Google.

Will Do.

Thanks Brian,

I will get in touch with Google about it and post back the outcome.



Same problem with Analytics as guy above

I really like your video and set everything up according to plan, I even checked the "closer" tag in the PHP file. Not sure why but still getting an error in GA saying its not tracking. Did we find out what the problem was?

This is the correct fix for my issue

Thanks man. I have created my own template and i for got to mention the closure statement..

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Subscribe to Drupal Screencasts (RSS)