diff --git a/datacenterlight/templates/datacenterlight/base.html b/datacenterlight/templates/datacenterlight/base.html index bf0e0ca0..f4f659df 100644 --- a/datacenterlight/templates/datacenterlight/base.html +++ b/datacenterlight/templates/datacenterlight/base.html @@ -33,6 +33,9 @@ + + {% include "google_analytics.html" %} + @@ -47,9 +50,6 @@ {% include "datacenterlight/includes/_footer.html" %} - - {% include "datacenterlight/includes/_google_analytics.html" %} - diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 8b53df5d..24511463 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -1,8 +1,7 @@ {% extends "hosting/base_short.html" %} {% load staticfiles bootstrap3 %} {% load i18n %} -{% block content %} -{% include 'datacenterlight/includes/_google_analytics.html' %} +{% block content %}
{% if messages %}
diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index f3a80470..31723853 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -138,6 +138,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(PROJECT_DIR, 'cms_templates/'), + os.path.join(PROJECT_DIR, 'templates'), os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'), os.path.join(PROJECT_DIR, 'membership'), os.path.join(PROJECT_DIR, 'hosting/templates/'), @@ -161,7 +162,7 @@ TEMPLATES = [ "django.contrib.messages.context_processors.messages", 'sekizai.context_processors.sekizai', 'cms.context_processors.cms_settings', - 'datacenterlight.context_processor.google_analytics', + 'utils.context_processor.google_analytics', ], }, }, @@ -512,5 +513,7 @@ DCL_TEXT = env('DCL_TEXT') DCL_SUPPORT_FROM_ADDRESS = env('DCL_SUPPORT_FROM_ADDRESS') # Settings for Google analytics -GOOGLE_ANALYTICS_PROPERTY_ID = 'UA-62285904-9' -GOOGLE_ANALYTICS_DOMAIN = 'auto' +GOOGLE_ANALYTICS_PROPERTY_IDS = { + 'datacenterlight.ch': 'UA-62285904-9', + 'digitalglarus.ch': 'UA-62285904-2' +} diff --git a/datacenterlight/templates/datacenterlight/includes/_google_analytics.html b/templates/google_analytics.html similarity index 75% rename from datacenterlight/templates/datacenterlight/includes/_google_analytics.html rename to templates/google_analytics.html index d074dfd3..64dbae40 100644 --- a/datacenterlight/templates/datacenterlight/includes/_google_analytics.html +++ b/templates/google_analytics.html @@ -1,4 +1,3 @@ - {% if GOOGLE_ANALYTICS_PROPERTY_ID %} {% else %} -{% endif %} - \ No newline at end of file +{% endif %} \ No newline at end of file diff --git a/datacenterlight/context_processor.py b/utils/context_processor.py similarity index 52% rename from datacenterlight/context_processor.py rename to utils/context_processor.py index b49ea364..43c27336 100644 --- a/datacenterlight/context_processor.py +++ b/utils/context_processor.py @@ -6,11 +6,11 @@ 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: + host = request.get_host() + ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(host) + print(ga_prop_id) + if ga_prop_id: return { - 'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id, - 'GOOGLE_ANALYTICS_DOMAIN': ga_domain, + 'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id } - return {} + return {} \ No newline at end of file