Skip to content

Commit

Permalink
Merge pull request #3420 from rtfd/support-dashboard-analytics-code
Browse files Browse the repository at this point in the history
Add concept of dashboard analytics code
  • Loading branch information
ericholscher authored Dec 19, 2017
2 parents 2f8f4c2 + 919d93e commit 6fd8282
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/ethical-advertising.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Instead of using an existing ad network, we are building the model we want to ex
We don't track you, sell your data, or anything else.
We simply show ads to users, based on the content of the pages you look at.
We also give 10% of our ad space to :ref:`community projects <community-ads>`,
as our way of saying thanks to the open source community
as our way of saying thanks to the open source community.

We talk a bit below about :ref:`our worldview on advertising <ethical-info>`,
if you want to know more.
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def readthedocs_processor(request):
'PUBLIC_DOMAIN': getattr(settings, 'PUBLIC_DOMAIN', None),
'PRODUCTION_DOMAIN': getattr(settings, 'PRODUCTION_DOMAIN', None),
'USE_SUBDOMAINS': getattr(settings, 'USE_SUBDOMAINS', None),
'GLOBAL_ANALYTICS_CODE': getattr(settings, 'GLOBAL_ANALYTICS_CODE', 'UA-17997319-1'),
'GLOBAL_ANALYTICS_CODE': getattr(settings, 'GLOBAL_ANALYTICS_CODE'),
'DASHBOARD_ANALYTICS_CODE': getattr(settings, 'DASHBOARD_ANALYTICS_CODE'),
'SITE_ROOT': getattr(settings, 'SITE_ROOT', '') + '/',
'TEMPLATE_ROOT': getattr(settings, 'TEMPLATE_ROOT', '') + '/',
}
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def INSTALLED_APPS(self): # noqa
STRIPE_PUBLISHABLE = None

# Misc application settings
GLOBAL_ANALYTICS_CODE = 'UA-17997319-1'
GLOBAL_ANALYTICS_CODE = None
DASHBOARD_ANALYTICS_CODE = None # For the dashboard, not docs
GRAVATAR_DEFAULT_IMAGE = 'https://media.readthedocs.org/images/silhouette.png' # NOQA
OAUTH_AVATAR_USER_DEFAULT_URL = GRAVATAR_DEFAULT_IMAGE
OAUTH_AVATAR_ORG_DEFAULT_URL = GRAVATAR_DEFAULT_IMAGE
Expand Down
9 changes: 9 additions & 0 deletions readthedocs/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,21 @@ <h4>{% trans "Read the Docs" %}</h4>

</body>

{% if GLOBAL_ANALYTICS_CODE %}
<!-- BEGIN google analytics -->
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ GLOBAL_ANALYTICS_CODE }}']);
_gaq.push(['_trackPageview']);

{% if DASHBOARD_ANALYTICS_CODE %}
// Dashboard Analytics Code
_gaq.push(['user._setAccount', '{{ DASHBOARD_ANALYTICS_CODE }}']);
_gaq.push(['user._trackPageview']);
// End Dashboard Analytics Code
{% endif %}

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
Expand All @@ -204,5 +212,6 @@ <h4>{% trans "Read the Docs" %}</h4>

</script>
<!-- END google analytics -->
{% endif %}

</html>

0 comments on commit 6fd8282

Please sign in to comment.