Package: django-tracking-jl
This is a clone ofdjango-trackingis athttp://bitbucket.org/codekoala/django-trackingdjango-trackingis a simple attempt at keeping track of visitors to
Django-powered Web sites.  It also offers basic blacklisting capabilities.The offial and original repository fordjango-trackingis athttp://bitbucket.org/codekoala/django-tracking.FeaturesTracks the following information about your visitors:Session keyIP addressUser agentWhether or not they are a registered user and logged inWhere they came from (http-referer)What page on your site they last visitedHow many pages on your site they have visitedAllows user-agent filtering for visitor trackingAutomatic clean-up of old visitor recordsCan ban certain IP addresses, rendering the site useless to visitors from
those IP’s (great for stopping spam)The ability to have a live feed of active users on your websiteTemplate tags to:display how many active users there are on your sitedetermine how many active users are on the same page within your siteOptional “Active Visitors Map” to see where visitors are in the worldRequirementsAs far as I am aware, the only requirement for django-tracking to work is a
modern version of Django.  I developed the project on Django 1.0 alpha 2 and
beta 1.  It is designed to work with the newforms-admin functionality.If you wish to use a Google Map to display where your visitors are probably at,
you must have aGoogle Maps API key, which is free.  You
are required to have theGeoIP C API libraryinstalled.
You might want to grab theGeoLite City binaryunless you are a paying MaxMind
customer.  This is the data file thatdjango-trackinguses to translate an
IP into a location on the planet.  Configuring this feature is discussed later.InstallationDownloaddjango-trackingusingoneof the following methods:pipYou can download the package from theCheeseShopor use:pip install django-tracking-jlto download and installdjango-tracking.easy_installYou can download the package from theCheeseShopor use:easy_install django-tracking-jlto download and installdjango-tracking.Checkout from GitHubUse one of the following commands:git clone http://github.com/jlachowski/django-tracking.gitPackage DownloadDownload the latest.tar.gzfile from the downloads section and extract it
somewhere you’ll remember.ConfigurationFirst of all, you must add this project to your list ofINSTALLED_APPSinsettings.py:INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    ...
    'tracking',
    ...
)Runmanage.py syncdb.  This creates a few tables in your database that are
necessary for operation.Depending on how you wish to use this application, you have a few options:Visitor TrackingAddtracking.middleware.VisitorTrackingMiddlewareto yourMIDDLEWARE_CLASSESinsettings.py.  It must be underneath theAuthenticationMiddleware, so thatrequest.userexists.Automatic Visitor Clean-UpIf you want to have Django automatically clean past visitor information out
your database, puttracking.middleware.VisitorCleanUpMiddlewarein yourMIDDLEWARE_CLASSES.IP BanningAddtracking.middleware.BannedIPMiddlewareto yourMIDDLEWARE_CLASSESinsettings.py.  I would recommend making this the very first item inMIDDLEWARE_CLASSESso your banned users do not have to drill through any
other middleware before Django realizes they don’t belong on your site.Visitors on Page (template tag)Make sure thatdjango.core.context_processors.requestis somewhere in yourTEMPLATE_CONTEXT_PROCESSORStuple.  This context processor makes therequestobject accessible to your templates.  This application uses therequestobject to determine what page the user is looking at in a template
tag.Active Visitors MapIf you’re interested in seeing where your visitors are at a given point in
time, you might enjoy the active visitor map feature.  Be sure you have added a
line to your main URLconf, as follows:from django.conf.urls.defaults import *

urlpatterns = patterns('',
    ....
    (r'^tracking/', include('tracking.urls')),
    ....
)Next, set a couple of settings in yoursettings.py:GOOGLE_MAPS_KEY: Your very own Google Maps API keyTRACKING_USE_GEOIP: set this toTrueif you want to see markers on
the mapGEOIP_PATH: set this to the absolute path on the filesystem of yourGeoIP.datorGeoIPCity.dator whatever file.  It’s usually something
like/usr/local/share/GeoIP.dator/usr/share/GeoIP/GeoIP.dat.GEOIP_CACHE_TYPE: The type of caching to use when dealing with GeoIP data:0: read database from filesystem, uses least memory.1: load database into memory, faster performance but uses more
memory.2: check for updated database.  If database has been updated, reload
filehandle and/or memory cache.4: just cache the most frequently accessed index portion of the
database, resulting in faster lookups thanGEOIP_STANDARD, but less
memory usage thanGEOIP_MEMORY_CACHE- useful for larger databases
such as GeoIP Organization and GeoIP City.  Note, for GeoIP Country,
Region and Netspeed databases,GEOIP_INDEX_CACHEis equivalent toGEOIP_MEMORY_CACHE.defaultDEFAULT_TRACKING_TEMPLATE: The template to use when generating the
visitor map.  Defaults totracking/visitor_map.html.When that’s done, you should be able to go to/tracking/map/on your site
(replacingtrackingwith whatever prefix you chose to use in your URLconf,
obviously).  The default template relies upon jQuery for its awesomeness, but
you’re free to use whatever you would like.UsageTo display the number of active users there are in one of your templates, make
sure you have{% load tracking_tags %}somewhere in your template and do
something like this:{% visitors_on_site as visitors %}
<p>
    {{ visitors }} active user{{ visitors|pluralize }}
</p>If you also want to show how many people are looking at the same page:{% visitors_on_page as same_page %}
<p>
    {{ same_page }} of {{ visitors }} active user{{ visitors|pluralize }}
    {{ same_page|pluralize:"is,are" }} reading this page
</p>If you don’t want particular areas of your site to be tracked, you may define a
list of prefixes in yoursettings.pyusing theNO_TRACKING_PREFIXES.  For
example, if you didn’t want visits to the/family/section of your website,
setNO_TRACKING_PREFIXESto['/family/'].If you don’t want to count certain user-agents, such as Yahoo!’s Slurp and
Google’s Googlebot, you may add keywords to your visitor tracking in your
Django administration interface.  Look for “Untracked User-Agents” and add a
keyword that distinguishes a particular user-agent.  Any visitors with the
keyword in their user-agent string will not be tracked.By default, active users include any visitors within the last 10 minutes.  If
you would like to override that setting, just setTRACKING_TIMEOUTto however
many minutes you want in yoursettings.py.For automatic visitor clean-up, any records older than 24 hours are removed by
default.  If you would like to override that setting, setTRACKING_CLEANUP_TIMEOUTto however many hours you want in yoursettings.py.Good luck!  Please contact me with any questions or concerns you have with the
project!