Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple site GA_ID support #17

Open
jeffreyckchau opened this issue Apr 28, 2017 · 1 comment
Open

Multiple site GA_ID support #17

jeffreyckchau opened this issue Apr 28, 2017 · 1 comment

Comments

@jeffreyckchau
Copy link

With the work that's being done in Wagtail to support multiple sites per installation, are there any plans to update this package to allow a Wagtail instance to support multiple Google Analytics IDs and View IDs? That feature would be a huge help to us.

Right now we're hacking a solution by pulling in a specific ID from the site specific settings object using a cached request, but I don't think our approach would be general enough to reflect back into the upstream repository. I would love to get some input on ways to approach multitenancy in wagalytics.

@jordanmt
Copy link

I'm approaching this via custom Wagtail settings, but also hacking a solution that I'm not sure could serve as a common denominator. So here is my long-winded +1!

Here's what my approach has been so far:

  • I have an AnalyticsSettings Wagtail settings class that defines fields like my View ID
  • I replaced settings.GA_VIEW_ID with a settings.GA_VIEW_ID_SETTING constant that contains a string identifying the setting and attribute with the View ID, e.g. GA_VIEW_ID_SETTING = 'app.AnalyticsSettings.google_analytics_view_id'
  • In wagalytics.views, I've added a get_view_id_from_settings() function that breaks the above string down to fetch the actual attribute value via get_model() and getattr()

We are multi-tenanted owing to separate schemas, but Wagtail settings are site specific so I think think the above holds true for multi-site based mutli-tenancy.

From what I've done so far, I don't see an obvious way to now get the View ID into the insert_editor_js hook that displays the page counts on editing pages, but this isn't a feature we are currently using. I wonder if this is part of the reason you arrived at using a cached request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants