tomdyson / wagalytics

A Google Analytics dashboard in your Wagtail admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate analytics snippet as template tag

alexgleason opened this issue · comments

Perhaps you could have a template tag like:

{% load wagalytics %}
{% ga_snippet %}

This could benefit #8 since it seems that there's otherwise no way to directly control whether or not it displays.

The dynamic part of the snippet appears to be the property ID which you could pass directly into the tag (ex. {% ga_snippet property_id="XXXXX" %}), or perhaps as a setting (GA_PROPERTY_ID = "XXXXX"). I think it would be better to pass it directly into the tag, but that would prevent you from having different settings between dev and prod.

There are several existing GA template tags for Django. Best practice for GA snippets seems to be a moving target (in the <head>, before </body>, using Google Tag Manager?) and I think it's better if this module doesn't try to solve that problem.