• Stars
    star
    218
  • Rank 181,805 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Google Analytics dashboard in your Wagtail admin

Wagtail Analytics

(Last Updated 12/17/19 for Wagtail v2.x)

This module provides a simple dashboard of Google Analytics data, integrated into the Wagtail admin UI. Tested on Wagtail 2.0+.

Screenshot

Screenshot

Instructions

  1. Create a service account and download the JSON key (Credentials > Create Credentials > API key)
  2. Make sure the Analytics API is enabled for your project (See issue 2)
  3. Add the service account email address as a read-only user in Google Analytics (Admin > User Management)
  4. Find the ID for your Google Analytics property (Admin > Property > View Settings, note: this is NOT the key that begins with "UA-")
  5. Store your JSON key somewhere safe, and do not check it into your repo
  6. pip install wagalytics
  7. Add 'wagalytics' to your INSTALLED_APPS
  8. Add 'wagtailfontawesome' to INSTALLED_APPS if it's not there already
  9. Update your settings:
  • GA_KEY_FILEPATH = '/path/to/secure/directory/your-key.json'

or when using environment variables (e.g. Heroku):

  • GA_KEY_CONTENT = 'content_of_your_key.json'
  • GA_VIEW_ID = 'ga:xxxxxxxx'

If you get CryptoUnavailableError errors, you probably need to pip install PyOpenSSL and/or pip install pycrypto. See StackOverflow.

Ensure that your code snippet is included on each page you want to be tracked (likely by putting it in your base.html template.) (Admin > Property > Tracking Code)

Multisite Support

To enable multisite support you'll need to update your Wagalytics settings and have wagtail.contrib.settings installed. Sites can use a GA_KEY_FILEPATH or a GA_KEY_CONTENT key, but it's best not to use both.

In the snippet below, you'll see site_id. This is the ID (Primary Key) of your Wagtail Site.

# Use either the GA_KEY_FILEPATH or the GA_KEY_CONTENT setting on your sites,
# but don't use both
WAGALYTICS_SETTINGS = {
    site_id: {
        'GA_VIEW_ID': 'ga:xxxxxxxx',
        'GA_KEY_FILEPATH': '/path/to/secure/directory/your-key.json',
    },
    site_id: {
        'GA_VIEW_ID': 'ga:xxxxxxxx',
        'GA_KEY_CONTENT': 'content_of_your_key.json',
	}
}

For every Wagalytics site you add in your multisite WAGALYTICS_SETTINGS you'll need to make sure you have the proper GA View ID and API Key. One View ID and API Key won't work for all your sites automatically.

Here's a working example of multisite WAGALYTICS_SETTINGS:

WAGALYTICS_SETTINGS = {
	# My default site. 2 is the site ID. This one uses GA_KEY_FILEPATH.
    2: {
        'GA_VIEW_ID': 'ga:xxxxxxxx',
        'GA_KEY_FILEPATH': '/path/to/secure/directory/your-key.json',
    },
    # The secondary site. 3 is the Site ID. This one uses GA_KEY_CONTENT.
    3: {
        'GA_KEY_CONTENT': 'content_of_your_key.json',
        'GA_VIEW_ID': 'ga:xxxxxxxx',
    }
}

Wagalytics Developers

Developers will need to carry out the following steps after cloning wagalytics:

  • Ensure NodeJS & NPM are installed
  • Run npm install then npm run build in the top level wagalytics directory

You will need to run npm run build anytime the javascript source is updated.

TODO

  • allow configuration of results
  • better styling, e.g. using chart.js
  • Throw an error if the relevant settings aren't available
  • add per-page results

Notes

This module doesn't help with recording user activity. See the Wagtail docs and StackOverflow for pointers on how to avoid gathering data during preview and testing.

Contributors

  • Thijs Kramer
  • Stefan Schรคrmeli
  • Alex Gleason
  • James Ramm
  • Jake Kent
  • Kalob Taulien
  • Julius Parishy

More Repositories

1

wagtail-netlify

Wagtail <3 Netlify
Python
83
star
2

microllama

The smallest possible LLM API
Python
67
star
3

wordoff

A web service for stripping HTML cruft pasted from Word into WYSIWYG editors
Python
31
star
4

dolphy

Fast full-text indexing and search in Python
Python
8
star
5

octodata

Tools for getting your Octopus Energy electricity data into a SQLite database
Python
6
star
6

wagtail-model-maker

LLM-powered Web UI and CLI for stubbing out Wagtail page models
Python
6
star
7

cromongo

MongoDB / Django CRM
5
star
8

prettyprompt

Keeping your prompts clean since 2023
Python
5
star
9

wagtail-fakenews

Create fake Wagtail pages
Python
3
star
10

BBC-Recipe-Web-Scraper

A web scraper to grab all recipes from the BBC's website.
Python
3
star
11

trickle

Activity streaming, in construction
JavaScript
3
star
12

varnishings

Experiments in combining app fragments with Varnish/ESI
JavaScript
2
star
13

climatevote

"I'll vote for whoever takes climate change most seriously"
Python
2
star
14

nldb

natural language database queries
Python
2
star
15

serverlessness

Notes from my Serverlessness talk at DjangoCon EU 2017
2
star
16

nuxt-wagtail-api-poc

Vue
2
star
17

wagtail-mux

Manage Mux videos in Wagtail
2
star
18

imgcrnchr

Single view Django app for cached, on-demand JPG compression.
Python
2
star
19

django-sqlite-load-tests

Python
2
star
20

test-prompts

A collection of prompts to test LLMs
2
star
21

tomd

Minimal Wagtail site for tomd.org
Python
1
star
22

wagtail-docs-vuepress

Vuepress demo
JavaScript
1
star
23

jamdocs

Vue
1
star
24

beatmap-eleventy

JavaScript
1
star
25

wagtail-pulse

JavaScript
1
star
26

roh-stream-poc

Experiments in React Native for TV
JavaScript
1
star
27

nuxt-tailwind-netlifycms

Vue
1
star
28

tomdyson.org

new blog using wagtail
JavaScript
1
star
29

tomd-nuxt-fe

Vue
1
star
30

beatmap-gatsby

JavaScript
1
star
31

lylesightings

track sightings of lyles
Python
1
star
32

wagtail-migration

An example app for importing json to a NewsPage model
Python
1
star
33

synod

opinionated auto-scaling for Heroku dynos
1
star