Add GOOGLE_ANALYTICS_PROPERTY_IDS for dynamic set ID

This commit is contained in:
Andrii Marynets 2017-06-30 01:23:35 +03:00
commit 2ad984504c
5 changed files with 18 additions and 18 deletions

View file

@ -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.
"""
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
}
return {}