Skip to content

Commit

Permalink
Add documentation for new analytics integration
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Jun 12, 2021
1 parent dad1ac3 commit deaf7ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 27 additions & 10 deletions docs/setup/setting-up-site-analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:

``` yaml
google_analytics:
- UA-XXXXXXXX-X
- auto
```
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`:

=== "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

Expand All @@ -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
Expand Down

0 comments on commit deaf7ae

Please sign in to comment.