Giter VIP home page Giter VIP logo

lindat_piwik_reports's Introduction

Custom PIWIK reports for CLARIN Dspace

A python application to periodically retrieve the PIWIK counts and store them locally in lucene index for generation of quick custom dspace statistics reports.

Requirements

access to piwik mysql database

Setup

Clone the git project.

git clone --recurse-submodules https://github.com/ufal/custom_piwik_reports.git [PATH]

install python requirements

pip install -r new_importer/requirements.txt

create new_importer/config.py:

db_config = {
    'host': 'localhost',
    'user': 'reports',
    'password': '',
    'database': 'piwik_db'
}

output_dir = '/tmp/new_reports/'

output_dir should be set according to nginx.conf

see the nginx/conf/nginx.conf or run

docker run -v "$(pwd)"/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro -v "$(pwd)"/nginx/var/www:/var/www -d -p 8080:80 --name lindat_stats nginx

Which expect the output_dir to be nginx/var/www/statistics/

Initializing the reports

To retrive all the data from PIWIK server use the following command:

python new_importer/generate_reports.py

Create a cron job to periodically retrive the statistics. currently no update implemented; full import takes aprox 20 min.

API

/statistics/

The default route will return the timestamp of last run of the cron job.

/statistics/views

Return the yearly page views of all services.

Generated using the Actions.get PIWIK command.
returns nb_pageviews and nb_uniq_pageviews

/statistics/visits

Return the yearly visits of all services.

Generated using the VisitsSummary.get PIWIK command.
returns nb_visits and nb_uniq_visitors

Please note that nb_uniq_visitors metric for years is not enable by default in PIWIK.

/statistics/country

Return the yearly countrywise visits.

Generated using the UserCountry.getCountry PIWIK command.
returns nb_visits and nb_uniq_visitors with two letter country code.

/statistics/urls

Return the yearly hits by specific urls.

Generated using the Actions.getPageUrls PIWIK command.
returns nb_hits and nb_visits with label of the page.

nb_hits is equivalent to nb_pageviews

/statistics/handle?h=[handle]

Return the views for specific handle. with country=true return the top 10 countries

API Params

All the above routes can be customized using following url parameters.

period

year, month or day

date

YYYY[-MM][-DD]

month and day is optional.

segment

Segment can have the following values:

repository, downloads, lrt, lrt-downloads, others, services

for /handle the segment can be views or downloads

Not providing segment will return the overall counts combining all.

Example

Return monthly visits for repository

/statistics/visits?segment=repository&period=month

Integration in Joomla

Use the joomla.html file to create an article with piwik_charts.js javascript.

jqplot is required to generate the charts.

Add the dependencies mentioned in https://github.com/ufal/piwik-charts#how-to-use (js, css) and also:

<link href="js/lib/jquery-jvectormap-2.0.3.css" rel="stylesheet" type="text/css" />
<script src="js/lib/jquery-jvectormap-2.0.3.min.js" type="text/javascript"></script>
<script src="js/lib/jquery-jvectormap-world-mill.js" type="text/javascript"></script>
<script src="piwik-charts/lib/jqplot/plugins/jqplot.categoryAxisRenderer.min.js" type="text/javascript"> </script>
<script src="piwik-charts/lib/jqplot/plugins/jqplot.pointLabels.min.js" type="text/javascript"> </script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.