Ticket #937 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

Record download stats for resources (extension)

Reported by: rgrp Owned by: sebbacon
Priority: major Milestone: ckan-v1.4-sprint-5
Component: ckan Keywords: extension contributor simple js
Cc: Repository: ckan
Theme: none

Description (last modified by rgrp) (diff)

As a User (especially as a Package Owner/Maintainer?) I want to know how many times a resource has been downloaded (and when).

So let's record download stats (as in clicks on the link for a resource).

Implementation

Old Spec (do it in CKAN)

  • Record info of form: resource id (or url?), timestamp
  • Do this via javascript capturing of onclick event talking to an api
  • API: /api/resource/{id}/download
    • POST to increment (how do we stop spamming -- could use a nonce setup with a random string set on each page load for the js)
    • GET to get data back { total: X, day_count: [ [yyyy-mm-dd, count], ... ] }

Questions

  • Do we record ip addresses (to handle de-botting etc)?
  • Do we count preview clicks as well?

Change History

comment:1 Changed 3 years ago by sebbacon

Could consider using third-party analytics tracking here, which will also give referrer etc data for free?

Would probably be bes provided in the form of optional piwik or google analytics integration. Being able to say in the UI how many downloads there have been would need piwik.

comment:2 Changed 3 years ago by rgrp

  • Keywords extension contributor simple js added
  • Owner set to rgrp
  • Description modified (diff)
  • Milestone changed from ckan-v1.4 to ckan-v1.4-sprint-2

comment:3 Changed 3 years ago by sebbacon

I did a very quick hacky thing at the end of last week on top of the "insert google analytics code" extension we discussed, to work out "most popular packages" based off data harvested from the Google Analytics API. Needs making generic, tests etc but could be a starting point: https://bitbucket.org/sebbacon/ckanext-googleanalytics/src

comment:4 Changed 3 years ago by sebbacon

(and it would also need some proper caching as the GA API is very slow)

comment:5 Changed 3 years ago by sebbacon

  • Owner changed from rgrp to sebbacon
  • Status changed from new to assigned
  • Milestone changed from ckan-v1.4-sprint-2 to ckan-v1.4-sprint-3

comment:6 Changed 3 years ago by sebbacon

The current implementation I referenced above will be a good starting point.

Work that remains:

  • Add download click tracking to individual download links (currently we just record page views for packages, not downloads)
  • Somehow cache the download stats against each package (the Google API is very slow); package reddis or sqlite or similar as a local storage for the extension
  • Expose download information in the relevant places in the UI (all users? package owners? where?)

This is about 2 days' work. Unlikely to get it done in this sprint.

comment:7 Changed 3 years ago by sebbacon

  • Repository set to ckan
  • Theme set to none
  • Milestone changed from ckan-v1.4-sprint-3 to ckan-v1.4-sprint-4

comment:8 Changed 3 years ago by sebbacon

  • Milestone changed from ckan-v1.4-sprint-4 to ckan-v1.4-sprint-5

comment:9 Changed 3 years ago by sebbacon

  • Status changed from assigned to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.