Skip to content

Commit

Permalink
Make Google Analytics tracking optional.
Browse files Browse the repository at this point in the history
Some OpenStack contributors have expressed concern about having Google
Analytics tracking codes embedded in all of the HTML documentation
generated by the use of this theme. In addition to these concerns, which
mostly focus on privacy, having the Google Analytics tracking code used
widely runs the risk of creating misleading analytics data.

This change adopts an approach used by the Alabaster theme, which
enables Google Analytics tracking to be optional. Tracking is now
controlled by the theme settings in conf.py using a new theme option,
'analytics_tracking_code'. If present, this causes the HTML to include
the analytics tracking, with the provided code being used. If not
present, the Google Analytics snippet is excluded from the
documentation.

To avoid breakage, this commit uses the current hard-coded Google
Analytics tracking code as the default value of the option, which
means that most users will not notice any change and may continue to be
accidentally opted in to Google Analytics tracking.

Change-Id: I156151c3f458931f13716b4a32087afe57483794
  • Loading branch information
Lukasa committed Dec 5, 2015
1 parent 8bce804 commit 89b0475
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openstackdocstheme/theme/openstackdocs/layout.html
Expand Up @@ -13,17 +13,19 @@
{% if favicon %}
<link rel="shortcut icon" href="{{ pathto('_static/favicon.ico') }}"/>
{% endif %}
{% if theme_analytics_tracking_code %}
<!-- Google Analytics -->
<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', 'UA-17511903-1', 'auto');
ga('create', '{{ theme_analytics_tracking_code }}', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
{% endif %}
</head>
<body>
{% include 'header.html' %}
Expand Down
3 changes: 3 additions & 0 deletions openstackdocstheme/theme/openstackdocs/theme.conf
Expand Up @@ -2,3 +2,6 @@
inherit = basic
stylesheet = css/basic.css
pygments_style = native

[options]
analytics_tracking_code = UA-17511903-1
5 changes: 5 additions & 0 deletions releasenotes/notes/disable_analytics-45d98d6fab71d2b1.yaml
@@ -0,0 +1,5 @@
---
features:
- Google Analytics tracking may now be controlled by
setting the ``analytics_tracking_code`` option, or
removed entirely by leaving that option blank.

0 comments on commit 89b0475

Please sign in to comment.