Skip to content

fix(docs): add GA4 consent mode to enable analytics tracking#230

Merged
polaz merged 1 commit intomainfrom
fix/#229-ga4-consent-mode
Jan 26, 2026
Merged

fix(docs): add GA4 consent mode to enable analytics tracking#230
polaz merged 1 commit intomainfrom
fix/#229-ga4-consent-mode

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 25, 2026

Summary

  • Add default consent configuration for GA4 to enable analytics tracking
  • Without consent mode, GA4 blocks all data collection by default

Root Cause

GA4 requires explicit gtag('consent', 'default', {...}) before config. The analytics_storage was implicitly denied, blocking all tracking despite gtag.js loading successfully.

Changes

  • Grant analytics_storage to allow page view tracking
  • Deny ad_storage, ad_user_data, ad_personalization (privacy-focused, no ads)

Fixes #229

- Add default consent configuration before gtag config
- Grant analytics_storage to allow page view tracking
- Deny ad_storage, ad_user_data, ad_personalization (no ads)

Fixes #229
Copilot AI review requested due to automatic review settings January 25, 2026 22:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds GA4 Consent Mode initialization in the VitePress docs theme so GA4 can send analytics data (page views) while keeping advertising-related storage denied.

Changes:

  • Set gtag('consent', 'default', ...) before GA4 initialization to allow analytics_storage.
  • Explicitly deny ad_storage, ad_user_data, and ad_personalization to avoid ads-related tracking.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@polaz polaz merged commit aac2fa5 into main Jan 26, 2026
26 checks passed
@polaz polaz deleted the fix/#229-ga4-consent-mode branch January 26, 2026 00:04
sw-release-bot bot pushed a commit that referenced this pull request Jan 26, 2026
## [6.48.2](v6.48.1...v6.48.2) (2026-01-26)

### Bug Fixes

* **docs:** add GA4 consent mode to enable analytics tracking ([#230](#230)) ([aac2fa5](aac2fa5)), closes [#229](#229)
@sw-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 6.48.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GA4 analytics not tracking due to missing consent mode

2 participants