dillonzq / LoveIt

❤️A clean, elegant but advanced blog theme for Hugo 一个简洁、优雅且高效的 Hugo 主题
https://hugoloveit.com
MIT License
3.38k stars 1.07k forks source link

Where to insert Google Analytics template (use Universal Analytics) #711

Open jamdodot opened 2 years ago

jamdodot commented 2 years ago

Describe the bug

I got a UA code from Google Analytics,and put it in config.toml .But i don't know which html file is public,and don't know where to insert template files as follows:

{{ if not .Site.IsServer }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}

when i put "{{ template "_internal/google_analytics_async.html" . }}" in /layouts/partials/footer.html Google Analytics can detect access in local debugging ,but once I deploy to Netlify, Google Analytics can't detect it。

Expected behavior

Where should I put this template file?

"_internal/google_analytics_async.html" in baseof.html?

Screenshots

image

Build Environment

Preview Environment

Additional Information

blog in github :https://github.com/jamdodot/jamdodot.top

Finally thanks!

lixd commented 2 years ago

once you config ua code to conig.toml like this

# Analytics config
# 网站分析配置
[params.analytics]
enable = true
# Google Analytics
[params.analytics.google]
  id = "xxxxxx"

is will works, need't to edit template.