diff --git a/datacenterlight/context_processor.py b/datacenterlight/context_processor.py new file mode 100644 index 00000000..b49ea364 --- /dev/null +++ b/datacenterlight/context_processor.py @@ -0,0 +1,16 @@ +from django.conf import settings + + +def google_analytics(request): + """ + Use the variables returned in this function to + render your Google Analytics tracking code template. + """ + ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_ID', False) + ga_domain = getattr(settings, 'GOOGLE_ANALYTICS_DOMAIN', False) + if not settings.DEBUG and ga_prop_id and ga_domain: + return { + 'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id, + 'GOOGLE_ANALYTICS_DOMAIN': ga_domain, + } + return {} diff --git a/datacenterlight/templates/datacenterlight/base.html b/datacenterlight/templates/datacenterlight/base.html index c62d92f7..bf0e0ca0 100644 --- a/datacenterlight/templates/datacenterlight/base.html +++ b/datacenterlight/templates/datacenterlight/base.html @@ -47,6 +47,9 @@ {% include "datacenterlight/includes/_footer.html" %} + + {% include "datacenterlight/includes/_google_analytics.html" %} + diff --git a/datacenterlight/templates/datacenterlight/includes/_google_analytics.html b/datacenterlight/templates/datacenterlight/includes/_google_analytics.html new file mode 100644 index 00000000..d074dfd3 --- /dev/null +++ b/datacenterlight/templates/datacenterlight/includes/_google_analytics.html @@ -0,0 +1,15 @@ + +{% if GOOGLE_ANALYTICS_PROPERTY_ID %} + +{% else %} + +{% endif %} + \ No newline at end of file diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index cb412558..8b53df5d 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -2,7 +2,7 @@ {% load staticfiles bootstrap3 %} {% load i18n %} {% block content %} - +{% include 'datacenterlight/includes/_google_analytics.html' %}