Skip to content

Commit deaf7ae

Browse files
committed
Add documentation for new analytics integration
1 parent dad1ac3 commit deaf7ae

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

docs/customization.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ directory:
152152
MkDocs will now use the new partial when rendering the theme. This can be done
153153
with any file.
154154

155-
### Overriding blocks <small>recommended</small> { data-toc-label="Overiding blocks" }
155+
### Overriding blocks <small>recommended</small> { data-toc-label="Overriding blocks" }
156156

157157
Besides overriding partials, it's also possible to override (and extend)
158158
_template blocks_, which are defined inside the templates and wrap specific

docs/setup/setting-up-site-analytics.md

+27-10
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,29 @@ analytics providers][2] can be used, too.
1818

1919
[:octicons-file-code-24: Source][3] · :octicons-milestone-24: Default: _none_
2020

21-
After heading over to your [Google Analytics][1] account to [create a new
22-
property][4] in order to obtain a unique tracking id of the form
23-
`UA-XXXXXXXX-X`, add it to `mkdocs.yml`:
24-
25-
``` yaml
26-
google_analytics:
27-
- UA-XXXXXXXX-X
28-
- auto
29-
```
21+
Material for MkDocs integrates with both, Google Analytics 4 and the now phasing
22+
out Universal Analytics (`UA-*`). Depending on the prefix of the property, add
23+
the following to `mkdocs.yml`:
24+
25+
=== "Google Analytics 4"
26+
27+
``` yaml
28+
extra:
29+
analytics:
30+
provider: google
31+
property: G-XXXXXXXXXX
32+
```
33+
34+
=== "Universal Analytics"
35+
36+
``` yaml
37+
extra:
38+
analytics:
39+
provider: google
40+
property: UA-XXXXXXXX-X
41+
```
3042

3143
[3]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/integrations/analytics.html
32-
[4]: https://support.google.com/analytics/answer/1042508
3344

3445
#### Site search tracking
3546

@@ -43,6 +54,12 @@ search tracking:
4354
4. Scroll down and enable __site search settings__
4455
5. Set the __query parameter__ to `q`.
4556

57+
_Site search tracking is not supported with Google Analytics 4 due to the much
58+
more complicated manual setup. If you want to set up site search tracking
59+
yourself, [this tutorial][4] might be a good start._
60+
61+
[4]: https://www.analyticsmania.com/post/track-site-search-with-google-tag-manager-and-google-analytics/
62+
4663
## Customization
4764

4865
### Other analytics providers

0 commit comments

Comments
 (0)