Skip to content

Configure Google Tag Gateway

Use Cloudflare Google Tag Gateway to serve your Google Tag Manager (gtm.js) script through your own first-party domain. This improves script resilience against ad-blockers and ITP without deploying a dedicated Server-Side GTM (sGTM) infrastructure.

Google Tag Gateway vs. Full Server-Side GTM

Google Tag Gateway acts exclusively as a first-party script delivery proxy—it is not a full Server-Side GTM (sGTM) container. Features that require a true server-side endpoint, such as API Order & Refund Recovery, are exclusive to dedicated sGTM environments (e.g., Stape or TAGGRS) and are not supported through Cloudflare Google Tag Gateway.


Configuration Steps

  1. Log in to your Cloudflare Dashboard.
  2. Use Quick search, look for Google Tag Gateway and click on it.

    Cloudflare Quick Search for Google Tag Gateway

  3. Select your Domain/Site.

  4. Click Configure.

    Cloudflare Web Tag Management Interface

  5. Enter your GTM Web Container ID (e.g., GTM-XXXXXX).

  6. Define your custom measurement path.

    Choose an Obscure Path

    To bypass intelligent ad-blockers and tracking prevention systems (ITP), ensure your path meets these requirements:

    • Uniqueness: Use a path not currently in use by your shop (avoid common paths like /api/ or /upload/).
    • Obfuscation: Avoid keywords like gtm, analytics, google, or tracking.
    • Recommended Example: Use neutral paths like /xyz.
  7. Ensure the Setup Tag option remains DISABLED in the configuration panel.

    Crucial: Disable Setup Tag

    Do not activate the "Setup Tag" option. The tracking module handles all tag deployments and dataLayer initializations. Enabling this in Cloudflare will cause duplicate tracking and data corruption.

    Disabling Setup Tag in Cloudflare

  8. Click Save to deploy the gateway.


Verification

Visit https://yourdomain.com/xyz/gtm.js?id=GTM-XXXXXX (replacing /xyz and GTM-XXXXXX with your values) in a browser. If properly configured, the browser will load the JavaScript file directly from your domain instead of returning a 404 error.


Map Cloudflare Gateway to the Module

After deploying the gateway in Cloudflare, configure the module to load the GTM script through your custom first-party path. Assuming your chosen path in Cloudflare is /xyz, follow these steps:

  1. Navigate to the module configuration in your PrestaShop Back Office.
  2. Open the Tag Manager tab and locate the Script URL field.
  3. Enter your full domain followed by the path and a trailing slash: https://yourdomain.com/xyz/
  4. Open the Google Analytics 4 tab and leave the Server Container URL field empty.
  5. Save the configuration.

Do Not Use the Gateway Path as Server Container URL

  • Script URL (https://yourdomain.com/xyz/): Requires the trailing slash (/) to load the gtm.js library from your first-party path.
  • Server Container URL: Always leave this field empty when using Google Tag Gateway. Entering the gateway path here forces GA4 into server-side transport mode (/g/collect) without forwarding the visitor's IP address, causing GA4 to geolocate traffic and purchases to Cloudflare's datacenter cities instead of your customers' actual locations.
  • API Order & Refund Recovery: Because Cloudflare Google Tag Gateway is not a true sGTM environment, server-to-server order and refund recovery via API cannot be used with this setup. If you require API recovery, deploy a dedicated sGTM container (such as Stape or TAGGRS) instead.