Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concept of dashboard analytics code #3420

Merged
merged 5 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is probably what i was thinking of in the related ops PR.

GLOBAL_ANALYTICS_CODE = None
DASHBOARD_ANALYTICS_CODE = None # For the dashboard, not docs
GRAVATAR_DEFAULT_IMAGE = 'https://media.readthedocs.org/images/silhouette.png' # NOQA
RESTRICTEDSESSIONS_AUTHED_ONLY = True
RESTRUCTUREDTEXT_FILTER_SETTINGS = {
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>