Skip to content

GoogleTagGateway

Source: src/Cloudflare/GoogleTagGateway/GoogleTagGateway.ts

Google Tag Gateway configuration for a Cloudflare zone (/zones/{zone_id}/settings/google-tag-gateway/config).

Google Tag Gateway serves Google Tag Manager / gtag.js first-party through the zone — requests to the configured endpoint path are proxied to Google by Cloudflare’s edge. The config is a zone-level singleton: there is one per zone and the PUT API is a full replace, so reconcile is a single idempotent upsert. Destroy restores the configuration the zone had before Alchemy first managed it (or disables the gateway when the zone had never configured it).

Enable Google Tag Gateway on a zone

const gateway = yield* Cloudflare.GoogleTagGateway.GoogleTagGateway("Analytics", {
zone: "example.com",
enabled: true,
endpoint: "/metrics",
measurementId: "G-XXXXXXXXXX",
hideOriginalIp: true,
});

Proxy a Google Tag Manager container without auto-installing the tag

const gateway = yield* Cloudflare.GoogleTagGateway.GoogleTagGateway("Gtm", {
zone: zone.zoneId,
enabled: true,
endpoint: "/collect",
measurementId: "GTM-XXXXXXX",
hideOriginalIp: false,
setUpTag: false,
});