Extension GA Report (Google Analytics Reporting)


Extension Basics

Title
GA Report (Google Analytics Reporting)
Name
ckanext-ga-report
Type
Public extension
Description
Detailed periodic reports of CKAN analytics from Google Analytics including totals per group, aimed at site managers
CKAN versions

~2.9, ~2.10, ~2.11

Show details
Download-Url (zip)
Download-Url commit date
2025-10-10
Url to repo
Category
Visualization & Analytics


Background Infos

Description (long)
Show details

Extension for creating detailed periodic reports of CKAN analytics data from Google Analytics. While ckanext-googleanalytics focuses on providing page view stats for recent periods (aimed at end users), ckanext-ga-report is designed for building regular periodic reports more suited to site managers for monitoring purposes. Uses CLI tools to download Google Analytics data for each time period into database tables, and provides web page reports for users to view the data. Supports monthly or other periodic reporting, bounce rate tracking for specific paths, and group-level analytics.

Version
0.1
Version release date
2025-10-10
Contact name
David Read
Contakt email
Contact Url
(not set)


Installation Guide

Configuration hints

Requirements: - CKAN 1.7.1+ - gdata (Python library) - google-api-python-client - Requires Google Analytics account with OAuth setup

Installation: 1. Activate CKAN python environment: $ pyenv/bin/activate

  1. Install extension: $ pip install -e git+https://github.com/datagovuk/ckanext-ga-report.git#egg=ckanext-ga-report

  2. Configure in development.ini (or similar): googleanalytics.id = UA-1010101-1 googleanalytics.account = Account name (e.g., data.gov.uk) googleanalytics.token.filepath = ~/pyenv/token.dat ga-report.period = monthly ga-report.bounce_url = /

    ga-report.bounce_url: Specific path to record bounce rate (typically /)

  3. Initialize database tables: $ paster initdb –config=../ckan/development.ini

    Run from src/ckanext-ga-report

  4. Enable plugin in ckan.plugins: ckan.plugins = ga-report

Authorization Setup: 1. Follow Google Analytics API instructions: https://developers.google.com/analytics/resources/tutorials/hello-analytics-api

  1. Create credentials.json file (use credentials.json.template as reference):

    • Visit Google APIs Console: https://code.google.com/apis/console
    • Sign in, create/use project
    • Activate Analytics API in Services pane
    • Go to API Access pane
    • Create OAuth 2.0 client ID
    • Set Application type: Installed application
    • Note: Client ID, Client secret, Redirect URIs
  2. Generate OAuth token file: $ paster getauthtoken –config=../ckan/development.ini

    Follow browser prompts to authorize

    Creates token.dat file

  3. Reference token file in CKAN config: googleanalytics.token.filepath = ~/pyenv/token.dat

Usage - Download GA Data: $ paster loadanalytics –config=../ckan/development.ini

Run from src/ckanext-ga-report

Period Options: - all: Data for all time (since 2010) - latest: Just the latest data (default) - YYYY-MM-DD: Data from this date onwards (inclusive)

Example: $ paster loadanalytics latest –config=../ckan/development.ini

Configuration Options: googleanalytics.id = UA-1010101-1 # Your Google Analytics tracking ID

googleanalytics.account = Account name # Account name (e.g., data.gov.uk) # Top level item at https://www.google.com/analytics

googleanalytics.token.filepath = ~/pyenv/token.dat # Path to OAuth token file

ga-report.period = monthly # Reporting period (monthly, weekly, etc.)

ga-report.bounce_url = / # Specific path to record bounce rate for # Typically / (home page)

Paster Commands: - initdb: Initialize database tables - loadanalytics : Download GA data for period - getauthtoken: Generate OAuth token file - fixtimeperiods: Fix time periods in database

Reports Available: - Analytics data by time period - Totals per group - Bounce rate for specified paths - Site manager-focused periodic reports

Difference from ckanext-googleanalytics: - ckanext-googleanalytics: Recent page view stats for end users - ckanext-ga-report: Periodic reports for site managers/monitoring - Focus on regular periodic data collection - Group-level analytics - Historical trend analysis

Troubleshooting: Error: “(ProgrammingError) relation ‘ga_url’ does not exist” - Solution: Run paster initdb step successfully - Ensure config path is correct - Check database connection

Development Status: Development

License: Open Government Licence (OGL) - Crown Copyright - Compatible with Creative Commons Attribution License - http://www.nationalarchives.gov.uk/doc/open-government-licence/

Developed by: Cabinet Office (UK Government)

Plugins to configure (ckan.ini)
# ga-report=ckanext.ga_report.plugin:GAReportPlugin
CKAN Settings (ckan.ini)
# googleanalytics.id = UA-1010101-1 # googleanalytics.token.filepath = ~/pyenv/token.dat # googleanalytics.account = Account name (e.g., data.gov.uk)
DB migration to be executed
ga-report
<< back to Extensions