| 1 |
============================ |
| 2 |
Analytics and usage services |
| 3 |
============================ |
| 4 |
|
| 5 |
The theme supports several web analytics services via the ``analytics`` option. It is configured |
| 6 |
by passing a dictionary with options. See the sections below for relevant |
| 7 |
options depending on the analytics provider that you want to use. |
| 8 |
|
| 9 |
.. code:: python |
| 10 |
|
| 11 |
html_theme_options = { |
| 12 |
# See below for options for each service |
| 13 |
"analytics": analytics_options, |
| 14 |
} |
| 15 |
|
| 16 |
Generally speaking, we recommend using Plausible over Google Analytics because |
| 17 |
it has a better story around user security and privacy. In addition, it is more |
| 18 |
open-source and transparent. In fact, |
| 19 |
`you can self-host a Plausible server <https://www.elvisduru.com/blog/how-to-self-host-plausible-analytics>`__. |
| 20 |
|
| 21 |
.. admonition:: Get a self-hosted Plausible server at ``scientific-python.org`` |
| 22 |
:class: tip |
| 23 |
|
| 24 |
If your documentation is for a package that is part of the SciPy / PyData |
| 25 |
ecosystem, they might be able to host a Plausible server for you at |
| 26 |
``https://views.scientific-python.org/<your-package>``. |
| 27 |
To ask about this, contact them on the social media platform of your choice |
| 28 |
and learn more at `scientific-python.org <https://scientific-python.org>`__. |
| 29 |
|
| 30 |
Plausible Analytics |
| 31 |
=================== |
| 32 |
|
| 33 |
`plausible.io <https://plausible.io>`__ can be used to gather simple |
| 34 |
and privacy-friendly analytics for the site. To configure, you will need to provide two things: |
| 35 |
|
| 36 |
- A URL pointing to the JavaScript analytics script that is served by your Plausible server |
| 37 |
- A domain that reflects where your documentation lives |
| 38 |
|
| 39 |
Plausible's JavaScript will be included in all HTML pages to gather metrics. |
| 40 |
The dashboard with analytics results will be accessible at ``https://<plausible-url>/<my-domain>``. |
| 41 |
|
| 42 |
.. code:: python |
| 43 |
|
| 44 |
html_theme_options["analytics"] = { |
| 45 |
# The domain you'd like to use for this analytics instance |
| 46 |
"plausible_analytics_domain": "my-domain", |
| 47 |
# The analytics script that is served by Plausible |
| 48 |
"plausible_analytics_url": "https://.../script.js", |
| 49 |
} |
| 50 |
|
| 51 |
.. seealso:: |
| 52 |
|
| 53 |
See the `Plausible Documentation <https://plausible.io/docs/plausible-script>`__ for more information about this script. |
| 54 |
|
| 55 |
Google Analytics |
| 56 |
================ |
| 57 |
|
| 58 |
If the ``google_analytics_id`` config option is specified (like ``G-XXXXXXXXXX``), |
| 59 |
Google Analytics' JavaScript is included in the HTML pages. |
| 60 |
|
| 61 |
.. code:: Python |
| 62 |
|
| 63 |
html_theme_options["analytics"] = { |
| 64 |
"google_analytics_id": "G-XXXXXXXXXX", |
| 65 |
} |