diff --git a/Doc/conf.py b/Doc/conf.py
index e292bdd5003b97..e38476a0b70506 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -323,7 +323,8 @@
html_context = {
"is_deployment_preview": os.getenv("READTHEDOCS_VERSION_TYPE") == "external",
"repository_url": repository_url.removesuffix(".git") if repository_url else None,
- "pr_id": os.getenv("READTHEDOCS_VERSION")
+ "pr_id": os.getenv("READTHEDOCS_VERSION"),
+ "enable_analytics": os.getenv("PYTHON_DOCS_ENABLE_ANALYTICS"),
}
# This 'Last updated on:' timestamp is inserted at the bottom of every page.
diff --git a/Doc/tools/templates/layout.html b/Doc/tools/templates/layout.html
index e931147813ae03..394ebee5f9e139 100644
--- a/Doc/tools/templates/layout.html
+++ b/Doc/tools/templates/layout.html
@@ -26,6 +26,9 @@
{% endblock %}
{% block extrahead %}
+ {% if builder == "html" and enable_analytics %}
+
+ {% endif %}
{% if builder != "htmlhelp" %}
{% if pagename == 'whatsnew/changelog' and not embedded %}