Skip to content

Conversation

@mattvollmer
Copy link

Add head.hbs template file to inject GA4 tracking code into mdBook-generated documentation.

Generated with cmux

Add head.hbs template file to inject GA4 tracking code into mdBook-generated documentation.

Generated with `cmux`
Add actual Google Analytics measurement ID: G-D1HL4PBRSY

Generated with `cmux`
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1 to +8
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-D1HL4PBRSY"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-D1HL4PBRSY');
</script>

Choose a reason for hiding this comment

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

P0 Badge Replacing mdBook head template with GA snippet breaks docs rendering

Adding docs/theme/head.hbs with only the GA script overrides mdBook’s default head.hbs rather than appending to it. The default template defines the meta charset, viewport, stylesheet links, and built-in JS; overriding it with just the analytics snippet will produce HTML pages without any of those resources, so the generated docs will render without CSS or behavior. To inject GA code you need to copy the upstream head.hbs and append the snippet, or use additional-js/additional-css instead of replacing the template.

Useful? React with 👍 / 👎.

@mattvollmer mattvollmer marked this pull request as draft October 30, 2025 18:13
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