@@ -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:
43544 . Scroll down and enable __ site search settings__
44555 . 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