This document guides developers on how to best combine Google tag gateway
with CDN (GTG) and server-side Tag Manager (SGTM). While both can function
independently, using them together offers the most robust and controlled
tagging setup.

## Google tag gateway setup options

1. [Google tag gateway with CDN](https://developers.google.com/tag-platform/tag-manager/gateway/setup-guide): The CDN serves Google scripts directly from your first-party domain for durability. Data is sent to Google through your first-party domain.
2. [Google tag gateway with SGTM](https://developers.google.com/tag-platform/tag-manager/server-side/dependency-serving?option=sgtm): The SGTM server handles *both* first-party script serving and data collection.
3. Google tag gateway with CDN + SGTM (Recommended): The CDN serves Google scripts directly from your first-party domain for durability, while a separate SGTM server manages data collection, enrichment, and control.

This guide focuses on migrating to or implementing the Recommended setup (Option
3), which combines the benefits of CDN-based script serving (lower cost, reduced
SGTM server load) with the advanced data control features of SGTM.

## Recommended Architecture

![GTG with SGTM + CDN recommended architecture.](https://developers.google.com/static/tag-platform/tag-manager/gateway/img/recommended_architecture.svg)

> [!IMPORTANT]
> **Key Term:** In this documentation, "CDN" is used as a broad term for your Edge-serving layer. This includes Content Delivery Networks (CDNs), Content Management Systems (CMS), or Load Balancers that can forward requests to external endpoints.

## Before you begin

This guide assumes you have administrator access to your Google Tag Manager web
container.

> [!IMPORTANT]
> **Important:** Google tag gateway using a CDN requires a same-origin setup (e.g., example.com/abjfo). While server-side Tag Manager can be hosted on a subdomain, the recommended combined setup uses a same-origin path for both script serving and data collection. These must be two different paths

    Fill in the following to populate the examples throughout this document:

    Your domain: example.com
    Tag serving path (GTG): /scripts
    Server-side path (SGTM): /metrics

<button value="gtg_to_sgtm">Existing SGTM: Add GTG with CDN</button> <button value="sgtm_to_gtg">Existing GTG with CDN: Add SGTM</button>
Pick an implementation option to see instructions.