tomdyson / wagalytics

A Google Analytics dashboard in your Wagtail admin
MIT License
217 stars 42 forks source link

Wagalytics Multisite Support #39

Closed KalobTaulien closed 4 years ago

KalobTaulien commented 4 years ago

Added in multisite Wagtail support. Each site can be configured to hold its own GA View ID, and Key Content (or Key Filepath). If there's more than one site and the WAGALYTICS_SETTINGS are set, a site switcher will display (image below) image

Multisite support requires wagtail.contrib.settings to be enabled (not a problem for your website, but still a noteworthy point).

I've upgraded the re_path URLs to use Django paths. And also added Django Error Messages to the dashboard view to help guide setup.

Continued support for Single Site instances is included.

Added some basic tests, using PyTest. A proper GA VIEW ID and KEY.json (or content_of_KEY.json) is required.

drimacus182 commented 4 years ago

Does this PR eliminate per-page statistics added in 584e8aeb3122e337c1a3f95944aed94492c90c30 commit? (See insert_editor_js hook in wagtail/wagtail_hooks.py )

drimacus182 commented 4 years ago

It seems nobody is here :-(

jacobwegner commented 4 years ago

@drimacus182 Looks like the hook was broken under Wagtail 2.x and removed in this PR.

There has been some discussion on #23 on how to fix under Wagtail 2.x.

Here is a Gist with a working hook:

https://gist.github.com/jacobwegner/011ddeb93c5aeeccc9277eeb6ccaea56

You'd want to copy wagtail_hooks.py into your project (or add to an existing wagtail_hooks.py script):

https://docs.wagtail.io/en/stable/reference/hooks.html#hooks