Version 7 (modified by Karl Barker <karl.barker@…>, 5 years ago) (diff)


Trac Google Analytics Plugin

This is an external plugin, any questions and/or bugs should be submitted to:

Development on this project has been discontinued, and is up for adoption.

See #Patches at the bottom of this page for community-submitted patches.

Previously known as Google Analytics Plugin, this plugin will enable your trac environment to be logged by Google Analytics.

It adds the necessary javascript code to log your environment, plus, it also logs the downloads of regular filenames which end with a specific extension; these extensions are defined by you; and also external links.

Plugin has been renamed and package hierarchy has changed to join other trac plugins that addressed Google services.

Download and Install

The easiest way to install is using EasyInstall:

sudo easy_install TracGoogleAnalytics

Then, to enable the plugin add to the [components] section in your trac.ini:

[components]* = enabled


The necessary configuration is:
  • UID: Google Analytics' UID. The UID is needed for Google Analytics to log your website stats. Your UID can be found by looking in the JavaScript Google Analytics gives you to put on your page. Look for your UID in between the javascript:

    var pageTracker = _gat._getTracker("UA-111111-11");

    In this example you would put UA-11111-1 in the UID box.

There are other, more advanced configuration options:
  • admin_logging: Disabling this option will prevent all logged in TRAC_ADMIN's from showing up on your Google Analytics reports.

  • outbound_link_tracking: Disabling this option will turn off the tracking of outbound links. It's recommended not to disable this option unless you're a privacy advocate (now why would you be using Google Analytics in the first place?) or it's causing some kind of weird issue.

  • google_external_path: This will be the path shown on Google Analytics regarding external links. Consider the following link:

    <a href="">Trac</a>

    The above link will be shown as:


    This way you will be able to track outgoing links. Outbound link tracking must be enabled for external links to be tracked.

  • extensions: Enter any extensions of files you would like to be tracked as a download. For example to track all MP3s and PDFs enter mp3,pdf. Outbound link tracking must be enabled for downloads to be tracked.

  • tracking_domain_name: If you're tracking multiple subdomains with the same Google Analytics profile, like what's talked about here, enter your main domain here. For more info, please visit the previous link.

Bugs and/or New Features

Please submit bugs of new features to:

Source Code

If you wish to be on the bleeding edge and get the latest available code:

hg clone TracGoogleAds

Note: For up-to-date documentation please visit TracGoogleAnalytics's site.


The attachment attachment:tracgoogleanalyticsplugin_async.patch (added 10/04/2012):

  • Migrates the Google Tracking JS to use asynchronous methods
  • Performs JS string escaping on all strings injected into the webpage
  • Adds a 'restricted' config item, which lists URLs to be minimally tracked by Google Analytics

Attachments (1)

Download all attachments as: .zip