@@ -9,10 +9,10 @@ description: >-
9
9
10
10
## Adding Analytics
11
11
12
- The Docsy theme builds upon Hugo's support for [ Google Analytics] [ ] , which Hugo
13
- provides through [ internal templates] [ ] . Once you set up analytics as described
14
- below, usage information for your site (such as page views) is sent to your
15
- Google Analytics account.
12
+ The Docsy theme builds upon [ Hugo's support for Google Analytics] [ hugo-ga ] ,
13
+ which Hugo provides through [ internal templates] [ ] . Once you set up analytics as
14
+ described below, usage information for your site (such as page views) is sent to
15
+ your [ Google Analytics] [ ] account.
16
16
17
17
### Prerequisites
18
18
@@ -30,48 +30,30 @@ started** section of [Introducing Google Analytics 4 (GA4)][ga4-intro].
30
30
31
31
### Setup
32
32
33
- Add the following site parameter to your project's configuration file:
33
+ Enable Google Analytics by adding your project's analytics ID to the site
34
+ configuration file. For details, see [ Configure Google Analytics] [ ] .
34
35
35
- {{< tabpane persistLang=false >}}
36
- {{< tab header="Configuration file:" disabled=true />}}
37
- {{< tab header="config.toml" lang="toml" >}}
38
-
39
- googleAnalytics = "PUT-YOUR-ANALYTICS-ID-HERE"
40
-
41
- {{< /tab >}} {{< tab header="config.yaml" lang="yaml" >}}
36
+ {{% alert title="Warning" color="warning" %}}
37
+ <!-- Remove this warning once the Hugo docs have been updated to include it. -->
42
38
43
- googleAnalytics: PUT-YOUR-ANALYTICS-ID-HERE
39
+ You can configure your project's analytics ID by setting either the top-level
40
+ ` googleAnalytics ` config parameter or ` services.googleAnalytics.id ` . ** Do not
41
+ define both** otherwise this will likely result in [ unexpected behavior] [ ] .
42
+ For details, see [ Is ` services.googleAnalytics.id ` an alias for
43
+ ` googleAnalytics ` ] [ alias-discussion ] .
44
44
45
- {{< /tab >}} {{< tab header="config.json" lang="json" >}}
46
- {
47
- "googleAnalytics": "PUT-YOUR-ANALYTICS-ID-HERE"
48
- }
45
+ [ alias-discussion ] : https://discourse.gohugo.io/t/config-is-services-googleanalytics-id-an-alias-for-googleanalytics/39469
46
+ [ unexpected behavior ] : https://github.com/google/docsy/issues/921
49
47
50
- {{< /tab >}}
51
- {{< /tabpane >}}
48
+ {{% /alert %}}
52
49
53
- {{% alert title="Production-only feature!" color="warning " %}}
50
+ {{% alert title="Production-only feature!" color="primary " %}}
54
51
55
52
Analytics are enabled _ only_ for ** production** builds (called "environments"
56
53
in Hugo terminology). For the information Hugo environments and how to set
57
54
them, see the following [ discussion] [ ] .
58
55
59
- [ discussion ] : https://discourse.gohugo.io/t/what-does-setting-hugo-env-to-production-do/24669/2?u=chalin
60
-
61
- {{% /alert %}}
62
-
63
- {{% alert title="Upgrade warning" color="warning" %}}
64
-
65
- Earlier versions of Docsy recommended setting the
66
- ` services.googleAnalytics.id ` config parameter to enable analytics. Upgrade
67
- your configuration as outlined above. ** Do not** set both this parameter _ and_
68
- the top-level ` googleAnalytics ` , otherwise this will likely result in
69
- [ unexpected behavior] [ ] . For more details about how these two parameters are
70
- related, see [ Is ` services.googleAnalytics.id ` an alias for
71
- ` googleAnalytics ` ] [ alias-discussion ] .
72
-
73
- [ alias-discussion ] : https://discourse.gohugo.io/t/config-is-services-googleanalytics-id-an-alias-for-googleanalytics/39469?u=chalin
74
- [ unexpected behavior ] : https://github.com/google/docsy/issues/921
56
+ [ discussion ] : https://discourse.gohugo.io/t/what-does-setting-hugo-env-to-production-do/24669/2
75
57
76
58
{{% /alert %}}
77
59
@@ -315,6 +297,8 @@ Then the meta `description` tag on the rendered page is:
315
297
316
298
You can add additional meta tags to your own copy of the ` head-end.html ` partial. See [ Customizing templates] ({{< ref "lookandfeel#customizing-templates" >}}) for more information.
317
299
300
+ [ Configure Google Analytics ] : https://gohugo.io/templates/internal/#configure-google-analytics
318
301
[ ga4-intro ] : https://support.google.com/analytics/answer/1042508
319
302
[ Google Analytics ] : https://analytics.google.com/analytics/web/
320
- [ internal templates ] : https://gohugo.io/templates/internal/#google-analytics
303
+ [ hugo-ga ] : https://gohugo.io/templates/internal/#google-analytics
304
+ [ internal templates ] : https://gohugo.io/templates/internal/
0 commit comments