Add ability to enable Google analytics for production sites
This commit is contained in:
parent
360a2c67a6
commit
6022eb15d5
3 changed files with 23 additions and 0 deletions
|
@ -88,6 +88,7 @@ TEMPLATES = [
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
'social_django.context_processors.backends',
|
'social_django.context_processors.backends',
|
||||||
'social_django.context_processors.login_redirect',
|
'social_django.context_processors.login_redirect',
|
||||||
|
'django_settings_export.settings_export',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -145,6 +146,14 @@ USE_TZ = True
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
GOOGLE_ANALYTICS_ID=None
|
||||||
|
|
||||||
|
SETTINGS_EXPORT = [
|
||||||
|
'DEBUG',
|
||||||
|
'GOOGLE_ANALYTICS_ID',
|
||||||
|
]
|
||||||
|
|
||||||
|
# Keep this at the end of settings.py to allow overriding settings in local deployments
|
||||||
try:
|
try:
|
||||||
from local_settings import *
|
from local_settings import *
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,18 @@
|
||||||
|
|
||||||
<title>Get Together</title>
|
<title>Get Together</title>
|
||||||
|
|
||||||
|
{% if settings.GOOGLE_ANALYTICS_ID %}
|
||||||
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{settings.GOOGLE_ANALYTICS_ID}}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
|
||||||
|
gtag('config', '{{settings.GOOGLE_ANALYTICS_ID}}');
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Bootstrap core CSS -->
|
<!-- Bootstrap core CSS -->
|
||||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous" rel="stylesheet">
|
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous" rel="stylesheet">
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet">
|
||||||
|
@ -24,6 +36,7 @@ form {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
|
@ -16,3 +16,4 @@ social-auth-app-django==2.1.0
|
||||||
social-auth-core==1.6.0
|
social-auth-core==1.6.0
|
||||||
urllib3==1.22
|
urllib3==1.22
|
||||||
dj-database-url==0.4.2
|
dj-database-url==0.4.2
|
||||||
|
django-settings-export==1.2.1
|
||||||
|
|
Loading…
Reference in a new issue