How to add Google Analytics? #899
-
How can i add Google Analytics? Is it bundled in the theme or do i have To-Do IT manually? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Yes, it's bundled in the theme. You need to add the following code to your config file: https://gohugo.io/templates/internal/#configure-google-analytics (I assume you are using the latest version of Hugo, which changed the field used to config Google Analytics.) I see that you are using the starter template. You can past the following code into [services]
[services.googleAnalytics]
googleAnalytics = 'G-MEASUREMENT_ID' |
Beta Was this translation helpful? Give feedback.
-
For any 2024 reader, hugo changed [services]
[services.googleAnalytics]
ID = 'G-MEASUREMENT_ID' |
Beta Was this translation helpful? Give feedback.
Yes, it's bundled in the theme. You need to add the following code to your config file:
https://gohugo.io/templates/internal/#configure-google-analytics
(I assume you are using the latest version of Hugo, which changed the field used to config Google Analytics.)
I see that you are using the starter template. You can past the following code into
config/_default/config.toml
and it should work: