Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Google Analytics dashboard in your Wagtail admin

License

NotificationsYou must be signed in to change notification settings

tomdyson/wagalytics

Repository files navigation

(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 theAnalytics API is enabled for your project (Seeissue 2)
  3. Add theservice 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 topip install PyOpenSSL and/orpip install pycrypto. SeeStackOverflow.

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 settingsand havewagtail.contrib.settings installed. Sites can use aGA_KEY_FILEPATH or aGA_KEY_CONTENT key, but it's best not to use both.

In the snippet below, you'll seesite_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 bothWAGALYTICS_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 multisiteWAGALYTICS_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
  • Runnpm install thennpm run build in the top level wagalytics directory

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

TODO

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

Notes

This module doesn't help with recording user activity. Seethe Wagtail docs andStackOverflow 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

[8]ページ先頭

©2009-2025 Movatter.jp