{"title":"Google Tag Manager first-party gateway","slug":"google-tag-manager","url":"https://support.storeconnect.com/articles/google-tag-manager","url_markdown":"https://support.storeconnect.com/articles/google-tag-manager.md","subtitle":null,"summary":"Route Google Tag Manager scripts and measurement hits through your own store domain using the built-in first-party GTM gateway, configured via two store variables.","type":"Help_Documentation","video_url":"","keywords":"Google Tag Manager, GTM, first-party gateway, gtm_gateway, fps.goog, server-side tagging, ad blocker bypass, ITP, Intelligent Tracking Prevention, store variables, gtm_gateway.host, gtm_gateway.path, GTM proxy, analytics, ecommerce events, purchase event, cart.add event, GTM script, measurement hits, first-party domain, Google Analytics","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"StoreConnect includes a built-in first-party gateway for Google Tag Manager (GTM). When configured, GTM script requests and measurement hits are proxied through your store's own domain instead of Google's servers. This helps avoid ad blockers and browser tracking restrictions (such as Intelligent Tracking Prevention) that commonly block third-party analytics requests.\n\n:::note\nThis feature requires your Google account to have server-side tagging and a first-party domain configured in Google Tag Manager. See [Google's first-party mode documentation](https://developers.google.com/tag-platform/tag-manager/server-side/first-party-tagging) for setup instructions.\n:::\n\n## How the gateway works\n\nOnce configured, requests to a path on your store domain (e.g. `https://yourstore.com/metrics/`) are transparently proxied to your GTM first-party host (`*.fps.goog`). This covers both:\n\n- **Script downloads** — e.g. `GET /metrics/gtag/js?id=G-XXXXXX` retrieves the GTM initialization script\n- **Measurement hits** — e.g. `POST /metrics/g/collect` sends event data to Google Analytics\n\nYour customers' browsers only communicate with your domain; the proxy forwards requests to Google on their behalf.\n\n## Prerequisites\n\n- A Google Tag Manager account with server-side tagging configured\n- A first-party GTM host provisioned by Google (format: `gtm-XXXXXX.fps.goog`)\n- A StoreConnect store with [Store variables](store-variables) access\n\n## Configure the gateway\n\nAdd the following [Store variables](store-variables) to your store:\n\n| Variable | Value | Description |\n|----------|-------|-------------|\n| `gtm_gateway.host` | Your fps.goog hostname (e.g. `gtm-abcdef.fps.goog`) | The first-party GTM host provisioned by Google. Must end in `.fps.goog`. |\n| `gtm_gateway.path` | URL path prefix (e.g. `metrics`) | The path under which GTM requests will be served on your domain. Do not include leading or trailing slashes. |\n\nWith the example values above, requests to `https://yourstore.com/metrics/` are proxied to `https://gtm-abcdef.fps.goog/metrics/`.\n\n## Add the GTM initialization script\n\nAfter configuring the store variables, add the GTM initialization script to your store using a [Script block](adding-custom-javascript-css-and-head-content) or the store's Head Content field. Replace the standard Google Tag Manager script URL with your proxied path:\n\n```html\n\n\u003cscript async src=\"/metrics/gtag/js?id=G-XXXXXXXXXX\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n  gtag('config', 'G-XXXXXXXXXX');\n\u003c/script\u003e\n```\n\nReplace `metrics` with the path you configured in `gtm_gateway.path`, and `G-XXXXXXXXXX` with your Google Analytics measurement ID.\n\n## Built-in ecommerce events\n\nStoreConnect automatically fires the following ecommerce events through the event system when GTM is configured:\n\n| Event | When it fires |\n|-------|---------------|\n| `purchase` | When a customer completes a checkout and an order is confirmed |\n| `cart.add` | When a customer adds a product to their cart |\n\nThe `purchase` event includes transaction details (order reference, total, tax, shipping) and a line item for each product in the order.\n\nCustom events can be added by theme developers using Liquid controller templates. See [Liquid controllers](liquid-controllers) for details.\n\n## Troubleshooting\n\n- **Requests not being proxied**: Verify both `gtm_gateway.host` and `gtm_gateway.path` store variables are set. The gateway is disabled if either is missing.\n- **Host validation error**: The `gtm_gateway.host` value must end in `.fps.goog`. Other domains are rejected to prevent security issues.\n- **Upstream errors**: If Google's fps.goog service is unavailable, the gateway returns a 502 error. The store remains operational — only analytics collection is affected."}