Skip to content

Add config-driven GTM, Meta Pixel, and Facebook verification#459

Open
vittorio88 wants to merge 1 commit intodevcows:masterfrom
lagobello:feature/config-driven-tracking
Open

Add config-driven GTM, Meta Pixel, and Facebook verification#459
vittorio88 wants to merge 1 commit intodevcows:masterfrom
lagobello:feature/config-driven-tracking

Conversation

@vittorio88
Copy link
Contributor

@vittorio88 vittorio88 commented Mar 15, 2026

Summary

Adds optional, config-driven support for three common tracking/verification tools:

  • Google Tag Manager (gtm_id) — head script + body noscript fallback
  • Meta/Facebook Pixel (meta_pixel_id) — tracking pixel with noscript fallback
  • Facebook Domain Verification (facebook_domain_verification) — meta tag

All are opt-in: if the param is not set, nothing is rendered.

Configuration

Add any combination to config.toml / hugo.toml:

[params]
    facebook_domain_verification = "your-verification-code"
    meta_pixel_id = "your-meta-pixel-id"
    gtm_id = "GTM-XXXXXXX"

Files changed

  • 4 new partials: facebook-verification.html, gtm-head.html, gtm-body.html, meta-pixel-head.html
  • headers.html: includes head-level partials
  • All 5 layout files (index, single, list, page/single, 404): GTM body noscript after <body>
  • exampleSite/hugo.toml: commented-out example config

Test plan

  • Run example site without params — verify no tracking code in output
  • Add gtm_id and verify GTM script in <head> and noscript after <body>
  • Add meta_pixel_id and verify pixel code in <head>
  • Add facebook_domain_verification and verify meta tag in <head>

…cation

New partials driven by site params:
- gtm_id: Google Tag Manager (head script + body noscript)
- meta_pixel_id: Meta/Facebook Pixel
- facebook_domain_verification: Facebook domain verification meta tag

All are optional — if the param is not set, nothing is rendered.
GTM body noscript is injected in all 5 layout files after <body>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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