New Google Analytics module

Hi all,
Continuing our recent theme of “awesome things nobody has even thought of yet”, I’ve just rolled out a new (somewhat experimental) module to make it easy for your users to make use of[a href=“”>Google Analytics</a>. As you know, Virtualmin automatically sets up Webalizer and AWstats, which are cool packages. But, there’s a lot of data about website usage that neither of those packages has easy access to. Conveniently, Google does, and they let you see it for free in the form of really nice looking graphs. All around Google Analytics rocks pretty good, but I don’t know many people using it, because it requires a few tricky bits. This module takes away a couple of the tricky bits (you still have to sign up and get an ID).
The way this module works is it automatically adds a mod_perl filter to your Apache process for any domains for which Analytics is enabled. The filter injects the magic JavaScript string with the users ID in just the right place on every page, no matter how it was generated (static HTML put in place via FTP/SSH or the WYSIWYG editor, PHP script, Perl script, Ruby script, SSI, whatever). Your user doesn’t need to know where to edit template files or even how to edit HTML, and they don’t have to ask for any customer support, either (probably…we’ll have to see if the UI provides enough guidance for folks).
Anyway, this module rocks and I’ve already started using it, and Jamie is a bloody genius (I watched him write it during dinner at YCombinator Tuesday night while James Hong was talking about[a href=“”>HOT or NOT</a>).
Now, of course, you’d like to get on with it! So, to install it, first make sure you’ve got mod_perl. I believe this is kinda default for everybody except the Debian-ites and Ubuntuns. So, for you guys, we’ll add an extra package to your install list (we might need to configure it too…I’ll have to poke around a bit to see, and will post more to this thread in the news forum later).
To install on Red Hat based systems:
yum install wbm-virtualmin-google-analytics
On SUSE systems:
yast -i wbm-virtualmin-google-analytics
On Mandriva systems:
urpmi.update -a
urpmi wbm-virtualmin-google-analytics
And on Debian and Ubuntu systems:
apt-get update
apt-get install webmin-vritualmin-google-analytics libapache2-mod-perl2
To install on systems using .wbm and .wbt packages, download the module from:
Using your serial number as the username and your license key as the password. Then install it using the Webmin Modules module.
Finally, you’ll have to enable it for any domains that you’d like to use this feature on. Once enabled, the domain owner can click the Google Analytics option from the Services menu and fill in their UID (which is an identifier that looks like “UA-2498289-1”, which you get by signing up at the Google Analytics page).
As always, let us know about any bugs you find. And let us know if you or your users find the UI uninformative or difficult to use. It’s a sort of vague concept, but we believe it’s a lot easier than figuring out which files need to be edited within your CMS, blog, wiki, issue tracker, whatever, as well as every static page you serve up. (Also, feel free to tell all of your web developer and system administrator friends how awesome Virtualmin is for automating this.)

"Once enabled, the domain owner can click the Google Analytics option from the Services menu"

This implies (to me) looking under "Virtualmin->Services".

I didn’t find it there. After a lot of searching, I found it under Webmin->Servers->Google Analytics Reporting.

If I click on a domain name (to activate), it says Error 404, page not found for every domain, so it’s not working for me…

Be careful - this module appears to be a bit buggy right now! See details below…

First, these are the steps I used to set it up:

  1. Using the Virtualmin Framed Theme, expand the System Settings category and click on Plugin Modules. (If you’re using another theme, this should appear as a button near the bottom of the main Virtualmin page.)

  2. Control-click to enable the Google Analytics Tracking plugin, and click Save.

  3. Select the domain you wish to add this feature to, and click on Edit Virtual Server.

  4. Under the Enabled Features section, select "Enable Google Analyics tracking?" and click Save Virtual Server.

  5. Now, under the Services category in the left frame menu, click on the new option for Google Analytics Account (for that same domain).

  6. Click on Set To, enter your UID, and click Save.

Now, here’s the bad part: ALL OF MY WEBSITES WERE COMPLETELY DOWN! Apache refused to start, with the following error:

failed to load Virtualmin::GoogleAnalytics package

… along with a long list of Perl errors prior to that, which I can post separately.

So, I quickly tried to disable this module to undo what it did so I could get Apache to start back up. First, I tried to disable the plugin entirely. That didn’t work. Then, I re-enabled the plugin so I could disable it from the one server I added it to. That didn’t work either. Finally, I found the lines that it added in apache.conf for that virtual server and commented them out:

#PerlRequire /etc/webmin/virtualmin-google-analytics/
#PerlOutputFilterHandler Virtualmin::GoogleAnalytics
#PerlSetVar AnalyticsID UA-xxxxxxx-x

At that point, I was able to restart Apache successfully (without this feature).

I had the same problem that post #3 had and have completely removed this module. It is VERY unstable and should be considered ALPHA code and NOT BETA which would imply that it is pretty much stable and it isn’t.

Needs much more testing before actual usage.

But really is this module needed? The GA code is so simple to put into the website pages I think this module is more of a toy then a helpful module.

FYI, I have submitted the following bug reports:

<A HRef="">Bug #715</A>: New Google Analytics Plug-in Breaks Apache

<A HRef="">Bug #716</A>:Error Disabling Google Analytics

<A HRef="">Bug #717</A>:Google Analytics Reporting Module Error

<A HRef="">Bug #718</A>:RFE: Google Analytics Reporting Module vs. Virtualmin Plugin

New 1.1 has been released which refuses to break your Apache config if only the old mod_perl is available. I’m packaging mod_perl2 for everyone as we speak to correct remaining issues.

Hey Scott,

I had the same problem that post #3 had and have completely removed this module. It is VERY unstable and should be considered ALPHA code and NOT BETA which would imply that it is pretty much stable and it isn’t.

Needs much more testing before actual usage.

Yep, it freaks out with old mod_perl. Sorry for the inconvenience. There’s a new version that won’t freak out, and will safely refuse to work with mod_perl 1.99 and below. I’m packaging mod_perl2 for everyone now.

But really is this module needed? The GA code is so simple to put into the website pages I think this module is more of a toy then a helpful module.

For you and me, it’s super easy. For someone who wants to run a blog or wiki or forum (and used Install Scripts to install it) while still getting good analytics, it’s probably not easy at all…maybe even impossible. You have to know where to find the end body tag in the right templates directory within your application(s)–and you need to know how to edit HTML to insert it without breaking things.

These are assumptions that we can safely make about most of our current users–like you and Alan–but going forward we want everyone (everyone, everyone) to be able to make interesting, good looking, and useful web pages, and learn useful things about their readership. As you know, we’re building tools for the hard core guys like you, and we’ve been doing that for years. But now, we’re trying to make Virtualmin useful for the folks who have never built a website. Screwing up your Apache configuration is clearly not the right way to do that–so we went back to the drawing board quick-like–but allowing non-technical Virtualmin users to make use of cool tools like Google Analytics is definitely a win for most of those folks.

I actually find it pretty nifty too–because I no longer have to think about “OK, did I get that tag added to all of my various applications in all of my various templates and subdirectories”. We’ll be running several applications when the new website goes live (instead of the single platform we have now), and getting all of them into analytics is important to me. When it’s working right it adds the tag to every page served by Apache for the entire domain–no thought or searching for where to add it needed.

I believe our botched roll-out has given you a bad impression of the whole idea. Hopefully, when we get it fixed, you’ll come around. :wink:

As far as I can tell, I’ve got the prerequisites…
mod_perl 2.0.2-6.3.el5
Google analytics account, functional

I removed the urchin script from the footer of my wordpress template (was working fine and allowing Google data collection).

I have entered my Google Analytics account ID in "Virtualmin Analyics" (sic) for the domain, however Tracking Status reports "Enabled but no account set"

I can’t see any urchin script code inserted when I view source… is it inserted in apache header, or is supposed to be inserted in the html?

Update: it apparently was "somewhat" working, because it was adding an abbreviated urchin script to standard HTML files… but not php files.

"not php files" = "not Wordpress"

I haven’t tried the analytics deal with other php scripts/templates yet. I mostly use phpBB, Wordpress and Joomla.

Hmmm…Strange. There is an update to that module going into the repo today, so maybe there’s a bug that I wasn’t aware of.

It should work on HTML, PHP, CGI, whatever. That’s the fancy thing about it. If it doesn’t work in all of those contexts, then it fails at being fancy…and we refuse to fail at being fancy. :wink:

Looks like it’s working properly on standard versions of Joomla 1.0, 1.5 and Wordpress.

The particular Wordpress install I was having trouble with, I ended up doing the manual Google urchin script method (put urchin code in the footer.php theme file).

I haven’t figured out the problem yet, and I probably won’t sweat it… it could be a template issue… The auto-inserted analytics code is displaying on the admin pages and every other HTML or PHP page.

And that may be a problem… I don’t really want my admin pages tracked by Google. The nice thing about Google Analytics is that it tracks only your relevant content and legitimate visitors. Tailoring the logfile analysis tools to do the same thing is more difficult.

Also, a small criticism/correction: Analytics is misspelled Analyics (missing "t") most places in Virtualmin.

notice that "analytics" is spelled with a "t" ;¬)<br><br>Post edited by: PlayGod, at: 2007/12/21 15:24

Also, a small criticism/correction: Analytics is misspelled Analyics (missing "t") most places in Virtualmin.

I believe this is fixed in the version of the module I rolled out a couple of days ago, but I’ll double check.

Misspelled on "Edit Analyics Accounts" "Virtualmin Analyics" and in the checkbox choices on "Edit Virtual Server"

my v 1.5-1 is still reporting "Enabled but no account set" on "Virtualmin Analyics" page, though I have definitely enabled working accounts on several domains.


Webmin version 1.380
Virtualmin version 3.48 (Pro)
Operating system CentOS Linux 5
Apache version 2.2.3
PHP version 5
MySQL version 5.0.22

There is an update to the javascript code located on the google site.
will this new code be implemented soon?

unless the prot://sub.domain.tld.path/name.ext of the js has changed, it should be automatic. The js call the module inserts is

here is a sample of the new code

old code:

<script src="" type="text/javascript">
<script type="text/javascript">
_uacct = "UA-XXXXX-1";

new code:

<script type=“text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.“«»);
document.write(unescape(”%3Cscript src=’” + gaJsHost + "’ type=‘text/javascript’%3E%3C/script%3E"«»));
<script type=“text/javascript”>
var pageTracker = _gat._getTracker("UA-XXXXX-1"«»);

from google: Use this tracking code to gain access to a wide range of exciting new features as they become availabl
as they become available
So it's currently vaporware?

I’ll take a look at my Analytics account next week to see if it’s worth upgrading my urchins.

I would avoid this module anyway, it drops the urchin in every single html file rendered by the server, which is overkill and will give you more analytics results than you need.

It’s really better to just put it in your page templates so it only shows up on the pages you want to track.

doesn’t seem to work if you are using fastcgi with php

Anyone figure out a way to fix the fastcgi with php problem?

Mine works great with html sites… but my php sites don’t connect.