Skip to content

Commit

Permalink
ISSUE-467: Add google analytics (#468)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomas Zulberti <[email protected]>
  • Loading branch information
tzulberti and tzulberti-jampp authored Aug 15, 2020
1 parent b8249f1 commit 8a29dc5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion community/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def pyar_wiki_url(request):
from django.conf import settings
# return the value you want as a dictionnary. you may add multiple values in there.
return {'PYAR_WIKI_URL': settings.PYAR_WIKI_URL}
return {
'PYAR_WIKI_URL': settings.PYAR_WIKI_URL,
'GOOGLE_TRACKING_ID': settings.GOOGLE_TRACKING_ID,
}
12 changes: 11 additions & 1 deletion community/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@
<link rel="icon" href="{% static 'img/icons/pyar.ico' %}" type="image/ico">

{% block extra_head %}{% endblock %}

{% if GOOGLE_TRACKING_ID %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-169755710-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());


gtag('config', '{{ GOOGLE_TRACKING_ID }}');
</script>
{% endif %}
</head>
<body>

Expand Down
2 changes: 2 additions & 0 deletions pyarweb/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,5 @@
'font-size',
]
TAGGIT_CASE_INSENSITIVE = True

GOOGLE_TRACKING_ID = os.environ.get('GOOGLE_TRACKING_ID', '')

0 comments on commit 8a29dc5

Please sign in to comment.