Skip to content

feat(analytics): add Ahrefs Analytics tracker#503

Merged
tym83 merged 1 commit intomainfrom
feat/ahrefs-analytics
Apr 21, 2026
Merged

feat(analytics): add Ahrefs Analytics tracker#503
tym83 merged 1 commit intomainfrom
feat/ahrefs-analytics

Conversation

@tym83
Copy link
Copy Markdown
Contributor

@tym83 tym83 commented Apr 21, 2026

Summary

Add Ahrefs Analytics tracking to the site, alongside the existing Google Analytics integration.

What

  • New site param ahrefsAnalytics in hugo.yaml
  • Conditional <script> block in the Docsy layouts/partials/hooks/head-end.html extension point — renders only when the param is set

Why

Enables SEO visibility via Ahrefs. Param-driven so the tracking key lives in config rather than being hardcoded in layout templates.

Summary by CodeRabbit

  • New Features
    • Integrated Ahrefs analytics to the site for tracking user activity and monitoring site performance metrics.

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>
@tym83 tym83 requested review from kvaps and lllamnyp as code owners April 21, 2026 06:59
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 21, 2026

Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit e1171f8
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/69e72039ddeb5e0008a11b38
😎 Deploy Preview https://deploy-preview-503--cozystack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Ahrefs 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

Cohort / File(s) Summary
Analytics Configuration
hugo.yaml
Added ahrefsAnalytics parameter with tracking key sEZ/gu88M21DndmPulYRFw to site-wide params.
Analytics Script Loading
layouts/partials/hooks/head-end.html
Added conditional script tag to load Ahrefs analytics (https://analytics.ahrefs.com/analytics.js) when ahrefsAnalytics parameter is configured; passes parameter value to data-key attribute.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A tracking key tucked in the config so neat,
Ahrefs script loads with analytical beat,
Whiskers twitch as data flows true,
Site insights gathered, the whole rabbit crew! 🐇📊

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding Ahrefs Analytics tracking to the site. It accurately reflects the primary objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ahrefs-analytics

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +9 to +11
{{ with .Site.Params.ahrefsAnalytics }}
<script src="https://analytics.ahrefs.com/analytics.js" data-key="{{ . }}" async></script>
{{ end }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
{{ 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 }}

@tym83 tym83 merged commit 65f89c6 into main Apr 21, 2026
5 of 6 checks passed
@tym83 tym83 deleted the feat/ahrefs-analytics branch April 21, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant