Merge branch 'master' into task/3704/my_settings

This commit is contained in:
Arvind Tiwari 2017-08-29 17:42:40 +05:30
commit 32ba9c5ff7
7 changed files with 203 additions and 73 deletions

View file

@ -7,7 +7,14 @@ 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 = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS',
False).get(host[4:])
if not settings.DEBUG and ga_prop_id:
return {
'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id