[3.12] Add Plausible for docs metrics (GH-119977) (#120194)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Julien Palard <julien@palard.fr>
This commit is contained in:
Miss Islington (bot) 2024-06-07 09:42:37 +02:00 committed by GitHub
parent 59224b8fdc
commit 92a38e9874
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -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.

View file

@ -26,6 +26,9 @@
{% endblock %}
{% block extrahead %}
{% if builder == "html" and enable_analytics %}
<script defer data-domain="docs.python.org" src="https://plausible.io/js/script.js"></script>
{% endif %}
<link rel="canonical" href="https://docs.python.org/3/{{pagename}}.html" />
{% if builder != "htmlhelp" %}
{% if pagename == 'whatsnew/changelog' and not embedded %}