Add documentation for new analytics integration

This commit is contained in:
squidfunk 2021-06-12 13:49:23 +02:00
parent dad1ac39d5
commit deaf7aebc2
2 changed files with 27 additions and 10 deletions

View File

@ -152,7 +152,7 @@ directory:
MkDocs will now use the new partial when rendering the theme. This can be done
with any file.
### Overriding blocks <small>recommended</small> { data-toc-label="Overiding blocks" }
### Overriding blocks <small>recommended</small> { data-toc-label="Overriding blocks" }
Besides overriding partials, it's also possible to override (and extend)
_template blocks_, which are defined inside the templates and wrap specific

View File

@ -18,18 +18,29 @@ analytics providers][2] can be used, too.
[:octicons-file-code-24: Source][3] · :octicons-milestone-24: Default: _none_
After heading over to your [Google Analytics][1] account to [create a new
property][4] in order to obtain a unique tracking id of the form
`UA-XXXXXXXX-X`, add it to `mkdocs.yml`:
Material for MkDocs integrates with both, Google Analytics 4 and the now phasing
out Universal Analytics (`UA-*`). Depending on the prefix of the property, add
the following to `mkdocs.yml`:
``` yaml
google_analytics:
- UA-XXXXXXXX-X
- auto
```
=== "Google Analytics 4"
``` yaml
extra:
analytics:
provider: google
property: G-XXXXXXXXXX
```
=== "Universal Analytics"
``` yaml
extra:
analytics:
provider: google
property: UA-XXXXXXXX-X
```
[3]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/integrations/analytics.html
[4]: https://support.google.com/analytics/answer/1042508
#### Site search tracking
@ -43,6 +54,12 @@ search tracking:
4. Scroll down and enable __site search settings__
5. Set the __query parameter__ to `q`.
_Site search tracking is not supported with Google Analytics 4 due to the much
more complicated manual setup. If you want to set up site search tracking
yourself, [this tutorial][4] might be a good start._
[4]: https://www.analyticsmania.com/post/track-site-search-with-google-tag-manager-and-google-analytics/
## Customization
### Other analytics providers