2011-02-11 12:21:19 +01:00
|
|
|
A CKAN extension for doing things with Google Analytics:
|
|
|
|
|
2011-04-05 16:15:46 +02:00
|
|
|
* It puts the relevant tracking code in your templates for you
|
|
|
|
(including tracking code for external resource download links)
|
2011-02-11 12:21:19 +01:00
|
|
|
|
2011-04-06 11:05:33 +02:00
|
|
|
* It provides a page showing top packages and resources
|
|
|
|
|
|
|
|
* It inserts download stats onto individual package pages
|
2011-02-11 12:21:19 +01:00
|
|
|
|
|
|
|
Installation
|
|
|
|
============
|
|
|
|
|
|
|
|
1. Install the extension as usual, e.g.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ pip install -e hg+https://bitbucket.org/sebbacon/ckanext-googleanalytics#package=/ckanext-googleanalytics
|
|
|
|
|
|
|
|
2. Edit your development.ini (or similar) with:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
googleanalytics.id = UA-1010101-1
|
|
|
|
googleanalytics.username = googleaccount@gmail.com
|
|
|
|
googleanalytics.password = googlepassword
|
2011-04-05 16:28:27 +02:00
|
|
|
googleanalytics.show_downloads = true
|
2011-02-11 12:21:19 +01:00
|
|
|
# the following *must* match profile name in GA dashboard
|
2011-04-05 16:15:46 +02:00
|
|
|
googleanalytics.profile_name = mydomain.com
|
|
|
|
|
2011-04-05 16:28:27 +02:00
|
|
|
That last comment is worth emphasising. Due to the strange
|
|
|
|
relationship between tracking IDs and profiles, you need to get that
|
|
|
|
right. It's the relevant value in the "Name" column for the list of
|
|
|
|
"Website Profiles" that you see when you click on an Analytics Account
|
|
|
|
link in the Google Analytics homepage. E.g. you'll need two clicks
|
|
|
|
from the analytics home page to see the profile name. Sometimes your
|
|
|
|
profile name might have a trailing slash; you need to include that,
|
|
|
|
too, if so.
|
|
|
|
|
|
|
|
Note also that your password will probably be readable by other
|
|
|
|
people; so you may want to set up a new gmail account specifically
|
|
|
|
for accessing your gmail profile.
|
|
|
|
|
|
|
|
If ``show_downloads`` is set, a download count for resources will be
|
|
|
|
displayed on individual package pages.
|
2011-02-11 12:21:19 +01:00
|
|
|
|
2011-04-04 18:44:39 +02:00
|
|
|
3. Wait a day or so for some stats to be recorded in Google
|
2011-02-11 12:21:19 +01:00
|
|
|
|
2011-04-04 18:44:39 +02:00
|
|
|
4. Import Google stats by running the following command from
|
|
|
|
``src/ckanext-googleanalytics``::
|
|
|
|
|
|
|
|
paster loadanalytics --config=../ckan/development.ini
|
|
|
|
|
|
|
|
(Of course, pointing config at your specific site config)
|
|
|
|
|
|
|
|
5. Look at some stats within CKAN
|
2011-02-11 12:21:19 +01:00
|
|
|
|
|
|
|
Once your GA account has gathered some data, you can see some basic
|
|
|
|
information about the most popular packages at:
|
2011-04-05 16:15:46 +02:00
|
|
|
http://mydomain.com/analytics/package/top
|
2011-02-11 12:21:19 +01:00
|
|
|
|
2011-04-04 18:44:39 +02:00
|
|
|
By default the only data that is injected into the public-facing
|
|
|
|
website is on the package page, where number of downloads are
|
|
|
|
displayed next to each resource.
|
|
|
|
|
|
|
|
6. Consider putting the import command as a daily cron job, or
|
|
|
|
remember to run it by hand!
|
|
|
|
|
2011-04-05 16:08:24 +02:00
|
|
|
Testing
|
|
|
|
=======
|
|
|
|
|
|
|
|
There are some very high-level functional tests that you can run using::
|
|
|
|
|
|
|
|
(pyenv)~/pyenv/src/ckan$ nosetests --ckan ../ckanext-googleanalytics/tests/
|
|
|
|
|
|
|
|
(note -- that's run from the CKAN software root, not the extension root)
|
|
|
|
|
2011-04-06 11:05:33 +02:00
|
|
|
Future
|
|
|
|
======
|
|
|
|
|
|
|
|
This is a bare-bones, first release of the software. There are
|
|
|
|
several directions it could take in the future.
|
2011-02-11 12:21:19 +01:00
|
|
|
|
2011-04-06 11:05:33 +02:00
|
|
|
Because we use Google Analytics for recording statistics, we can hook
|
|
|
|
into any of its features. For example, as a measure of popularity, we
|
|
|
|
could record bounce rate, or new visits only; we could also display
|
|
|
|
which datasets are popular where, or highlight packages that have been
|
|
|
|
linked to from other locations.
|