feat(analytics): add Ahrefs Analytics tracker#503
Conversation
Wire Ahrefs analytics via `ahrefsAnalytics` site param, injected in the Docsy `head-end` hook next to Google Analytics. Script renders only when the param is set. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: tym83 <6355522@gmail.com>
✅ Deploy Preview for cozystack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAhrefs analytics integration is added to the Hugo site configuration and deployed via a conditional script tag in the page head template. The integration reads a configuration parameter and conditionally loads the analytics JavaScript. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request integrates Ahrefs Analytics into the website by adding a configuration parameter and including the tracking script in the head partial. The review feedback suggests wrapping the script in a production environment check to prevent tracking development traffic and improving the script's indentation for better readability.
| {{ with .Site.Params.ahrefsAnalytics }} | ||
| <script src="https://analytics.ahrefs.com/analytics.js" data-key="{{ . }}" async></script> | ||
| {{ end }} |
There was a problem hiding this comment.
It is recommended to wrap analytics scripts in an environment check (e.g., hugo.IsProduction) to prevent tracking development and staging traffic. This ensures that your production analytics data remains clean and accurate. Additionally, the script tag should be indented for better readability.
| {{ with .Site.Params.ahrefsAnalytics }} | |
| <script src="https://analytics.ahrefs.com/analytics.js" data-key="{{ . }}" async></script> | |
| {{ end }} | |
| {{ if hugo.IsProduction }} | |
| {{ with .Site.Params.ahrefsAnalytics }} | |
| <script src="https://analytics.ahrefs.com/analytics.js" data-key="{{ . }}" async></script> | |
| {{ end }} | |
| {{ end }} |
Summary
Add Ahrefs Analytics tracking to the site, alongside the existing Google Analytics integration.
What
ahrefsAnalyticsinhugo.yaml<script>block in the Docsylayouts/partials/hooks/head-end.htmlextension point — renders only when the param is setWhy
Enables SEO visibility via Ahrefs. Param-driven so the tracking key lives in config rather than being hardcoded in layout templates.
Summary by CodeRabbit