2
2
Bootstrap-based sphinx theme from the PyData community
3
3
"""
4
4
import os
5
- import warnings
6
5
from pathlib import Path
7
6
from functools import lru_cache
8
7
import json
@@ -86,18 +85,6 @@ def update_config(app, env):
86
85
87
86
# Add an analytics ID to the site if provided
88
87
analytics = theme_options .get ("analytics" , {})
89
- # deprecated options for Google Analytics
90
- # TODO: deprecate >= v0.12
91
- gid = theme_options .get ("google_analytics_id" )
92
- if gid :
93
- msg = (
94
- "'google_analytics_id' is deprecated and will be removed in "
95
- "version 0.11, please refer to the documentation "
96
- "and use 'analytics' instead."
97
- )
98
- warnings .warn (msg , DeprecationWarning , stacklevel = 2 )
99
- analytics .update ({"google_analytics_id" : gid })
100
-
101
88
if analytics :
102
89
# Plausible analytics
103
90
plausible_domain = analytics .get ("plausible_analytics_domain" )
@@ -112,29 +99,16 @@ def update_config(app, env):
112
99
}
113
100
app .add_js_file (** kwargs )
114
101
115
- # Two types of Google Analytics id.
102
+ # Google Analytics
116
103
gid = analytics .get ("google_analytics_id" )
117
104
if gid :
118
- # In this case it is "new-style" google analytics
119
- if "G-" in gid :
120
- gid_js_path = f"https://www.googletagmanager.com/gtag/js?id={ gid } "
121
- gid_script = f"""
122
- window.dataLayer = window.dataLayer || [];
123
- function gtag(){{ dataLayer.push(arguments); }}
124
- gtag('js', new Date());
125
- gtag('config', '{ gid } ');
126
- """
127
- # In this case it is "old-style" google analytics
128
- else :
129
- gid_js_path = "https://www.google-analytics.com/analytics.js"
130
- gid_script = f"""
131
- window.ga = window.ga || function () {{
132
- (ga.q = ga.q || []).push(arguments) }};
133
- ga.l = +new Date;
134
- ga('create', '{ gid } ', 'auto');
135
- ga('set', 'anonymizeIp', true);
136
- ga('send', 'pageview');
137
- """
105
+ gid_js_path = f"https://www.googletagmanager.com/gtag/js?id={ gid } "
106
+ gid_script = f"""
107
+ window.dataLayer = window.dataLayer || [];
108
+ function gtag(){{ dataLayer.push(arguments); }}
109
+ gtag('js', new Date());
110
+ gtag('config', '{ gid } ');
111
+ """
138
112
139
113
# Link the JS files
140
114
app .add_js_file (gid_js_path , loading_method = "async" )
0 commit comments