mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-05-30 20:11:42 -04:00
Added guide to set up site analytics
This commit is contained in:
@@ -13,6 +13,8 @@ configured through `mkdocs.yml`.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Social links
|
||||
|
||||
[:octicons-file-code-24: Source][1] ·
|
||||
:octicons-milestone-24: Default: _none_
|
||||
|
||||
@@ -75,7 +77,7 @@ For each entry, the following fields are available:
|
||||
|
||||
`name`
|
||||
|
||||
: :octicons-milestone-24: Default: _domain name from_ `link`, if available –
|
||||
: :octicons-milestone-24: Default: _domain name from_ `link`_, if available_ –
|
||||
This field is used as the link's `title` attribute and can be set to a
|
||||
discernable name to improve accessibility:
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ theme:
|
||||
|
||||
[4]: https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html#L71
|
||||
|
||||
### Emoji (icons)
|
||||
### Icons
|
||||
|
||||
[:octicons-file-code-24: Source][5] · [:octicons-workflow-24: Extension][6]
|
||||
|
||||
|
||||
75
docs/setup/setting-up-site-analytics.md
Normal file
75
docs/setup/setting-up-site-analytics.md
Normal file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
template: overrides/main.html
|
||||
---
|
||||
|
||||
# Setting up site analytics
|
||||
|
||||
As with any other service that is offered on the web, understanding how your
|
||||
documentation is actually used can be an essential success factor. While
|
||||
Material for MkDocs natively integrates with [Google Analytics][1], other
|
||||
analytics services can be used, too.
|
||||
|
||||
[1]: https://developers.google.com/analytics
|
||||
|
||||
## Configuration
|
||||
|
||||
### Site analytics
|
||||
|
||||
[:octicons-file-code-24: Source][2] · :octicons-milestone-24: Default: _none_
|
||||
|
||||
After heading over to your [Google Analytics][1] account to [create a new
|
||||
property][3] in order to obtain a new tracking id of the form `UA-XXXXXXXX-X`,
|
||||
add it to `mkdocs.yml`:
|
||||
|
||||
``` yaml
|
||||
google_analytics:
|
||||
- UA-XXXXXXXX-X
|
||||
- auto
|
||||
```
|
||||
|
||||
Publish and refresh your site, and you should see events bubbling up.
|
||||
|
||||
[2]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/integrations/analytics.html
|
||||
[3]: https://support.google.com/analytics/answer/1042508
|
||||
|
||||
### Site search analytics
|
||||
|
||||
Besides basic page views, _site search_ can also be tracked to better understand
|
||||
how people use your documentation and what they expect to find. To enable
|
||||
search tracking:
|
||||
|
||||
1. Go to your Google Analytics __admin settings__
|
||||
2. Select the property for the respective tracking code
|
||||
3. Go to the __view settings__ tab.
|
||||
4. Scroll down and enable __site search settings__
|
||||
5. Set the __query parameter__ to `q`.
|
||||
|
||||
## Customization
|
||||
|
||||
### Other analytics services
|
||||
|
||||
[:octicons-file-code-24: Source][2] ·
|
||||
:octicons-mortar-board-24: Difficulty: _easy_
|
||||
|
||||
In order to integrate another analytics service provider offering an
|
||||
asynchronous JavaScript-based tracking solution, you can [extend the theme][4]
|
||||
and [override the `analytics` block][5].
|
||||
|
||||
[4]: ../customization.md#extending-the-theme
|
||||
[5]: ../customization.md#overriding-blocks
|
||||
|
||||
### Instant loading
|
||||
|
||||
[:octicons-file-code-24: Source][2] ·
|
||||
:octicons-mortar-board-24: Difficulty: _easy_
|
||||
|
||||
If you're using [instant loading][6], you can use the `DOMContentSwitch` event
|
||||
to listen for navigation events and register a page view event with:
|
||||
|
||||
``` js
|
||||
document.addEventListener("DOMContentSwitch", function() {
|
||||
/* Register page event here */
|
||||
})
|
||||
```
|
||||
|
||||
[6]: setting-up-navigation.md#instant-loading
|
||||
Reference in New Issue
Block a user