Google Analytics: free advanced website statistics

Google Analytics is the free statistics package based on the excellent Urchin system.

For webmasters to make use of Google Analytics you would normally need to insert some Javascript containing the unique Google Analytics account number (in the format UA-XXXXXX-X) in to the header or footer of every page.

This could be achieved by editing the Drupal template page.tpl.php. However, this would then mean you cannot run multiple sites from the same base theme template.

This module allows you to enter your Google Analytics account number into the modules settings page located at ?q=admin/settings/googleanalytics. It will then automatically add the required Javascript to the footer of every page generated by Drupal.

The Drupal Google Analytics module is currently available from the module downloads.

Additional Features

The Drupal module also offers a bit more than basic tracking.

Role Tracking

Usually Google Analytics will track all users on a site, but you can also omit groups of users by Drupal role. Simply un-tick the role name on the settings page.

Profile / User segmentation

Google Analytics provides a rough mechanism called "segmentation" to track your users based on data about their them.

For every page hit that is logged by Google, you can also attach the user identifier, username, user roles to it. This can provide a good overview of what type of users visit what pages on your site.

If you've got the Core profile.module activated you'll find a list of all the profile fields which can be added to the tracking. This would allow you to track things like the gender of your users, the age group or their location!

Link tracking

Using some included JavaScript you can track downloads of files, mailto and outgoing links on your site. A textfield is provided where you can specify a list of file extensions that should be tracked. Separate each file extension with a '|' character. pdf|zip|doc

Advanced Settings

Advanced settings for Google Analytics are hidden away in the collapsed fieldset. Expand it and you'll find the following additional features.

If you find your site pages load slow due to a delay in fetching the urchin.js/ga.js file from Google's servers - there's the option to cache the urchin.js/ga.js file locally on your server for 1 day. In order to use this feature your site must be configured to serve public files.

If you wish to inject additional custom Google Analytics JavaScript code snippets, a large textarea is provided to dump your code snippets in. Just remember to remove the <script> ... </script> tags from the start and end of your snippet!

Development sponsored by Ixis IT.

Works better when turned on

a1tsal - April 13, 2008 - 04:32

In order for anything to happen, you need to check [i.e. turn on] at least one User Role. By default all are disabled, and the module does nothing.

You probably also want to uncheck the "legacy" checkbox unless you have a specific reason not to.

 
 

Drupal is a registered trademark of Dries Buytaert.