Google Analytics is Google's free statistics package, originally based on the Urchin system.
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.
The Drupal Google Analytics module is currently available from the module downloads.
The Drupal module also offers a bit more than basic tracking.
Allows you to provide a list of pages to track, or a list of pages not to track.
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 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!
The module provides functionality to track downloads of files, mailto and outgoing links on your site. Select the relevant options on the main Google Analytics settings page. A textfield is also provided where you can specify a list of file extensions that should be tracked. Separate each file extension with a '|' character.
To see the link tracking reports, go into your Google Analytics dashboard and click on the main Content menu item on the left. That should reveal the Event Tracking option.
Search and Adsense
Allows you to track internal search and track AdSense ads.
Allows you to send custom variables along with the Google Analytics tracking request. You can use node tokens to populate the value on pages that provide the node object.
Advanced settings for Google Analytics are hidden away in the collapsed fieldset. Expand it and you'll find the following additional features.
Cache tracking code
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.
Custom code snippets
<script> ... </script> tags from the start and end of your snippet! The "before" textarea sets variables prior to the actual trackPageview, then the "after" handles variables, and additional actions (like tracking in multiple accounts).
Original development of this module sponsored by Ixis IT.