Skip to content

Commit adafb7f

Browse files
leouiedaseisman
authored andcommitted
Add Google Analytics to measure site visitors (#314)
* Add Google Analytics to measure site visitors Add the tracking script to the documentation template so we can know how many people are visiting the docs and which pages they see the most. The data are anonymous and we do not store cookies to track users in other sites. This limits the amount of information we can get but is much more ethical and less creepy. * Add disclaimer about GA to footer * Add link to google analytics docs
1 parent c5c332c commit adafb7f

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

doc/_templates/footer.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{# Import the theme's layout. #}
2+
{% extends "!footer.html" %}
3+
4+
{%- block extrafooter %}
5+
<p>
6+
Built with <a href="http://sphinx-doc.org/">Sphinx</a>
7+
using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
8+
provided by <a href="https://readthedocs.org">Read the Docs</a>
9+
</p>
10+
<p>
11+
This website uses Google Analytics to gather usage statistics.
12+
However, it does not use cookies or track you across different websites.
13+
Page view data are used to help us improve the site and provide an estimate of the
14+
software usage.
15+
</p>
16+
{% endblock %}

doc/_templates/layout.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{# Import the theme's layout. #}
22
{% extends "!layout.html" %}
33

4+
{% block extrahead %}
5+
<!-- Google Analytics tracking code -->
6+
<!-- See https://developers.google.com/analytics/devguides/collection/analyticsjs/ for documentation. -->
7+
<!-- 'storage': 'none' disables cookies -->
8+
<script>
9+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
10+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
11+
Date();a=s.createElement(o),
12+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
13+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
14+
ga('create', 'UA-38125837-7', 'auto', {'storage': 'none'});
15+
ga('set', 'anonymizeIp', true);
16+
ga('send', 'pageview');
17+
</script>
18+
{% endblock %}
19+
420

521
{% block htmltitle %}
622
{% if title == '' or title == 'Home' %}

doc/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@
116116
pygments_style = "default"
117117
add_function_parentheses = False
118118
html_show_sourcelink = False
119-
html_show_sphinx = True
119+
html_show_sphinx = False
120120
html_show_copyright = True
121121

122122
# Theme config
123123
html_theme = "sphinx_rtd_theme"
124124
html_theme_options = {}
125+
repository = "GenericMappingTools/pygmt"
126+
commit_link = f'<a href="https://github.com/GenericMappingTools/pygmt/commit/{ __commit__ }">{ __commit__[:7] }</a>'
125127
html_context = {
126128
"menu_links": [
127129
(
@@ -152,8 +154,9 @@
152154
"gallery_dir": dict(
153155
zip(sphinx_gallery_conf["gallery_dirs"], sphinx_gallery_conf["examples_dirs"])
154156
),
155-
"github_repo": "GenericMappingTools/pygmt",
157+
"github_repo": repository,
156158
"github_version": "master",
159+
"commit": commit_link,
157160
}
158161

159162

0 commit comments

Comments
 (0)