Skip to content

Google Analytics / GTM integration #622

Description

@5k18a

Feature Request: GA4 / gtag.js support in Site Defaults

Current behavior

SEO Pro v7.12.2 supports google_verification (Google Search Console meta tag) in Site Defaults, but has no built-in support for Google Analytics 4 tracking code injection.

The CP Site Defaults panel (/cp/seo-pro/site-defaults) does not include a GA4 Measurement ID field. There is no documentation suggesting GA4 is supported.

When a google_analytics key is manually added to resources/addons/seo-pro.yaml, it is silently ignored — the gtag script is never rendered in <head>.

Blueprint.php only registers google_verification and bing_verification in the "Verification" section, with no analytics counterpart.

Expected behavior

Site Defaults should include a Google Analytics 4 Measurement ID field (e.g. G-XXXXXXXXXX) that, when filled in, automatically injects the standard gtag.js snippet into <head>:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

Why this belongs in SEO Pro

GA4 is a core part of any SEO workflow — traffic data in Google Analytics informs keyword targeting, content performance and conversion tracking. SEO Pro already handles the adjacent GSC verification tag. Adding GA4 alongside it (in the same "Verification" or a new "Analytics" section in Site Defaults) would complete the integration and remove the need for users to manually edit templates.

The old Universal Analytics era had similar requests for many CMS addons; GA4 is now the only supported Google Analytics product.

Workaround

Currently requires manually adding the gtag.js snippet to the layout template, bypassing SEO Pro entirely.

Environment

  • Statamic: 6.x
  • SEO Pro: 7.12.2
  • PHP: 8.4
  • Laravel: 13.x

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