Skip to content

GA4 analytics not tracking due to missing consent mode #229

@polaz

Description

@polaz

Problem

Google Analytics 4 (gtag) is loaded on gitlab-mcp.sw.foundation but no data is being sent to GA4.

Root Cause

GA4 requires explicit consent mode configuration. Without gtag('consent', 'default', {...}), the analytics_storage defaults to requiring consent, which blocks all tracking.

Debug findings:

  • google_tag_data.ics.usedDefault: false - no default consent set
  • google_tag_data.ics.active: false - consent mode not active
  • Direct fetch to /g/collect works (Status 204), so network is not blocked

Solution

Add default consent configuration before gtag('config', ...):

window.gtag("consent", "default", {
  analytics_storage: "granted",
  ad_storage: "denied",
  ad_user_data: "denied", 
  ad_personalization: "denied",
});

This grants analytics tracking while denying all advertising-related data collection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions