Hugo
Add a partial to your Hugo layout and every page you publish records visits in Databuddy.
Add the script
Create the partial
{{ if and (not hugo.IsServer) site.Params.databuddyClientID }}
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="{{ site.Params.databuddyClientID }}"
crossorigin="anonymous"
async
></script>
{{ end }}hugo server skips the script, so your own local visits aren't counted.
Set your Client ID
[params]
databuddyClientID = "YOUR_CLIENT_ID"Your Client ID is in the Databuddy dashboard under your website's Settings → General. Use config.toml if your website still has one.
Include it in your base layout
<body>
{{ block "main" . }}{{ end }}
{{ partial "databuddy.html" . }}
</body>If your theme owns baseof.html, copy it into your own layouts/_default/ first, or add the line to the theme's footer partial.
Run hugo, deploy, and visit a few pages. They appear on your dashboard.
Track clicks in your content
Add data-track-attributes to the script tag, then name elements in your Markdown:
<a href="/pricing" data-track="pricing_link_click" data-location="post">View pricing</a>Hugo strips raw HTML from Markdown by default. Allow it:
[markup.goldmark.renderer]
unsafe = trueTurn on more tracking
Add attributes to the script tag in your partial:
data-track-attributes
data-track-outgoing-links
data-track-web-vitals
data-track-errorsRelated
How is this guide?