From 682f123622ab30dbf28be2048b866beede714a6a Mon Sep 17 00:00:00 2001 From: Septatrix <24257556+Septatrix@users.noreply.github.com> Date: Mon, 16 Mar 2020 13:12:07 +0100 Subject: [PATCH 1/4] Add analytics_anonymize_ip option to theme --- docs/configuring.rst | 9 +++++++++ sphinx_rtd_theme/layout.html | 3 +++ sphinx_rtd_theme/theme.conf | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/configuring.rst b/docs/configuring.rst index 42b64340a..1edaf0611 100644 --- a/docs/configuring.rst +++ b/docs/configuring.rst @@ -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, 'logo_only': False, 'display_version': True, 'prev_next_buttons_location': 'bottom', @@ -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 + + :type: boolean + :default: ``False`` + + Enabling this will make it so the users’ IP addresses are anonymized + within Google Analytics. + .. confval:: canonical_url :type: URL diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index 3d6e6ee02..face92c3d 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -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 %} + ga('set', 'anonymizeIp', true); + {% endif %} ga('send', 'pageview'); diff --git a/sphinx_rtd_theme/theme.conf b/sphinx_rtd_theme/theme.conf index fd0521f02..164e339c1 100644 --- a/sphinx_rtd_theme/theme.conf +++ b/sphinx_rtd_theme/theme.conf @@ -6,6 +6,7 @@ pygments_style = default [options] canonical_url = analytics_id = +analythics_anonymize_ip = False collapse_navigation = True sticky_navigation = True navigation_depth = 4 @@ -15,4 +16,4 @@ logo_only = display_version = True prev_next_buttons_location = bottom style_external_links = False -style_nav_header_background = \ No newline at end of file +style_nav_header_background = From 01d52bfd7251964937a5b39ae24c2a9ec7c5454a Mon Sep 17 00:00:00 2001 From: Nils K <24257556+septatrix@users.noreply.github.com> Date: Fri, 27 Mar 2020 20:46:20 +0100 Subject: [PATCH 2/4] Fix typo and use tobool filter Co-Authored-By: Jesse Tan --- docs/configuring.rst | 4 ++-- sphinx_rtd_theme/layout.html | 2 +- sphinx_rtd_theme/theme.conf | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/configuring.rst b/docs/configuring.rst index 1edaf0611..e35e4553d 100644 --- a/docs/configuring.rst +++ b/docs/configuring.rst @@ -15,7 +15,7 @@ For example: html_theme_options = { 'canonical_url': '', 'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard - 'analythics_anonymize_ip': False, + 'analytics_anonymize_ip': False, 'logo_only': False, 'display_version': True, 'prev_next_buttons_location': 'bottom', @@ -102,7 +102,7 @@ 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 +.. confval:: analytics_anonymize_ip :type: boolean :default: ``False`` diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index face92c3d..153596439 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -228,7 +228,7 @@ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', '{{ theme_analytics_id }}', 'auto'); - {% if theme_analythics_anonymize_ip %} + {% if theme_analytics_anonymize_ip|tobool %} ga('set', 'anonymizeIp', true); {% endif %} ga('send', 'pageview'); diff --git a/sphinx_rtd_theme/theme.conf b/sphinx_rtd_theme/theme.conf index 164e339c1..91731083f 100644 --- a/sphinx_rtd_theme/theme.conf +++ b/sphinx_rtd_theme/theme.conf @@ -6,7 +6,7 @@ pygments_style = default [options] canonical_url = analytics_id = -analythics_anonymize_ip = False +analytics_anonymize_ip = False collapse_navigation = True sticky_navigation = True navigation_depth = 4 From 648da72f4f940c88542f2b0941fa2d21a3995777 Mon Sep 17 00:00:00 2001 From: Septatrix <24257556+Septatrix@users.noreply.github.com> Date: Fri, 27 Mar 2020 20:48:36 +0100 Subject: [PATCH 3/4] Simplify analytics_anonymize_ip description --- docs/configuring.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/configuring.rst b/docs/configuring.rst index e35e4553d..85cafffac 100644 --- a/docs/configuring.rst +++ b/docs/configuring.rst @@ -107,8 +107,7 @@ Miscellaneous options :type: boolean :default: ``False`` - Enabling this will make it so the users’ IP addresses are anonymized - within Google Analytics. + Anonymize visitor IP addresses in Google Analytics. .. confval:: canonical_url From 56753ad00562b9ea457ddfb1aad7d180bb58030a Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Thu, 8 Oct 2020 19:03:58 -0400 Subject: [PATCH 4/4] Update changelog.rst --- docs/changelog.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index caf8575f6..f178469a6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,11 @@ Changelog master ====== +New Features +------------ + +* New theme option to enable anonymous ip addresses when using Google Analytics (#889) + v0.5.0 ======