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 analytics_anonymize_ip option to theme #889

Merged
merged 7 commits into from Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/configuring.rst
Expand Up @@ -15,6 +15,7 @@ For example:
html_theme_options = {
'canonical_url': '',
'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
'analythics_anonymize_ip': False,
septatrix marked this conversation as resolved.
Show resolved Hide resolved
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
Expand Down Expand Up @@ -101,6 +102,14 @@ Miscellaneous options
If specified, Google Analytics' javascript is included in your pages.
Set the value to the ID provided to you by google (like ``UA-XXXXXXX``).

.. confval:: analythics_anonymize_ip
septatrix marked this conversation as resolved.
Show resolved Hide resolved

:type: boolean
:default: ``False``

Enabling this will make it so the users’ IP addresses are anonymized
septatrix marked this conversation as resolved.
Show resolved Hide resolved
within Google Analytics.

.. confval:: canonical_url

:type: URL
Expand Down
3 changes: 3 additions & 0 deletions sphinx_rtd_theme/layout.html
Expand Up @@ -228,6 +228,9 @@
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', '{{ theme_analytics_id }}', 'auto');
{% if theme_analythics_anonymize_ip %}
septatrix marked this conversation as resolved.
Show resolved Hide resolved
ga('set', 'anonymizeIp', true);
{% endif %}
ga('send', 'pageview');
</script>

Expand Down
3 changes: 2 additions & 1 deletion sphinx_rtd_theme/theme.conf
Expand Up @@ -6,6 +6,7 @@ pygments_style = default
[options]
canonical_url =
analytics_id =
analythics_anonymize_ip = False
septatrix marked this conversation as resolved.
Show resolved Hide resolved
collapse_navigation = True
sticky_navigation = True
navigation_depth = 4
Expand All @@ -15,4 +16,4 @@ logo_only =
display_version = True
prev_next_buttons_location = bottom
style_external_links = False
style_nav_header_background =
style_nav_header_background =