Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #236 from mozilla-services/179
Browse files Browse the repository at this point in the history
Add Google Analytics #179
  • Loading branch information
jaredlockhart committed Jan 19, 2016
2 parents f93f721 + 35b2d82 commit 2f3350f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions leaderboard/analytics_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.conf import settings


def analytics_context(request):
return {
'GOOGLE_ANALYTICS_ID': settings.GOOGLE_ANALYTICS_ID,
}
4 changes: 4 additions & 0 deletions leaderboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'leaderboard.analytics_context.analytics_context',
],
},
},
Expand Down Expand Up @@ -144,6 +145,9 @@
GIT_TAG = os.environ.get('GIT_TAG', 'UNKNOWN')
GIT_VERSION = os.environ.get('GIT_VERSION', 'UNKNOWN')

# Google Analytics
GOOGLE_ANALYTICS_ID = 'Unknown'

# Travis settings
if 'TRAVIS' in os.environ:
# SECURITY WARNING: keep the secret key used in production secret!
Expand Down
3 changes: 3 additions & 0 deletions leaderboard/settings_local.py.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ FXA_CLIENT_ID = 'TODO'
FXA_SECRET = 'TODO'
FXA_OAUTH_URI = 'TODO'
FXA_PROFILE_URI = 'TODO'

# Google Analytics
GOOGLE_ANALYTICS_ID = 'TODO'
12 changes: 11 additions & 1 deletion leaderboard/templates/home/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h2>How do I contribute?</h2>

{% block js %}
{{ block.super }}

<script src="{% static "lib/fetch/fetch.js" %}"></script>

{% if debug %}
Expand Down Expand Up @@ -73,4 +73,14 @@ <h2>How do I contribute?</h2>
}
}
</script>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ GOOGLE_ANALYTICS_ID }}', 'auto');
ga('send', 'pageview');
</script>
{% endblock %}

0 comments on commit 2f3350f

Please sign in to comment.