Add GOOGLE_ANALYTICS_PROPERTY_IDS for dynamic set ID
This commit is contained in:
parent
007fc794c3
commit
2ad984504c
5 changed files with 18 additions and 18 deletions
16
utils/context_processor.py
Normal file
16
utils/context_processor.py
Normal 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 {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue