Skip to content

Commit bec3625

Browse files
authored
document the analytics config option
1 parent 20ac4f8 commit bec3625

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

episodes/editing.md

+27
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,33 @@ have rearranged themselves to reflect that.
225225
::::::::::::::::::::::::::
226226
::::::::::::::::::::::::::::::::::::::::::
227227

228+
### Configuring web analytics
229+
The optional `analytics` field can be used to configure web analytics, e.g. with [Matomo](https://matomo.org/) or Google Analytics.
230+
There are currently three options for `analytics`:
231+
232+
1. `NULL`: disables tracking for that lesson. This is the default behviour, and is equivalent to omitting the `analytics` field from `config.yaml` altogether.
233+
2. `carpentries`: adds the tracking script needed for the lesson to be tracked by The Carpentries self-hosted Matomo system.
234+
This option works only for The Carpentries lessons: community-owned lessons cannot be tracked in the same way.
235+
3. `<user_string>`: allows the user to define their own tracker script string.
236+
For legibility, use the `|` symbol to indicate that the value of the YAML field will be split across multiple indented lines ([known as a 'literal block' in YAML](https://stackoverflow.com/a/21699210)).
237+
For example, to configure for Google Analytics:
238+
239+
```yaml
240+
analytics: |
241+
<!-- Global site tag (gtag.js) - Google Analytics -->
242+
<script async src='https://www.googletagmanager.com/gtag/js?id={YOUR TRACKING ID}#' ></script>
243+
<script>
244+
window.dataLayer = window.dataLayer || [];
245+
function gtag(){dataLayer.push(arguments);}
246+
gtag('js', new Date());
247+
248+
gtag('config', '{YOUR TRACKING ID}');
249+
</script>
250+
```
251+
252+
Tracking scripts configured with the `analytics` option are added to the footer element of the lesson website HTML.
253+
254+
228255
## `episodes/`
229256

230257
This is the folder where all the action is. It contains all of the episodes,

0 commit comments

Comments
 (0)