From 01b64fec88a469be13240b3b00c20b6e1c4bef3f Mon Sep 17 00:00:00 2001
From: "M.Ravi" <mondi.ravi@gmail.com>
Date: Thu, 24 Aug 2017 16:04:37 +0200
Subject: [PATCH] Attempt to fix no ga code in www. sites

---
 utils/context_processor.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/utils/context_processor.py b/utils/context_processor.py
index 740591ba..37544962 100644
--- a/utils/context_processor.py
+++ b/utils/context_processor.py
@@ -7,7 +7,13 @@ def google_analytics(request):
     render your Google Analytics tracking code template.
     """
     host = request.get_host()
-    ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(host)
+    ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(
+        host)
+    if ga_prop_id is None:
+        # Try checking if we have a www in host, if yes we remove
+        # that and check in the dict again
+        if host.startswith('www.'):
+            ga_prop_id = host[4:]
     if not settings.DEBUG and ga_prop_id:
         return {
             'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id