Google tag gateway for advertisers: Load Google scripts first-party

  • This article guides developers on serving Google scripts like gtm.js or gtag.js from their own servers using server-side tagging for a first-party data context.

  • Before starting, ensure you have a server container in Tag Manager, a tagging server setup, and a configured custom server domain.

  • Implementation involves configuring the client to load Google scripts through your server, updating the script source domain to your server, and verifying the script source using browser developer tools.

  • If using consent mode, you can further enhance control by setting up region-specific tag behavior after completing the implementation.

This document is for developers who use server-side tagging and want to serve Google scripts in a first-party context.

Google tag gateway for advertisers lets you load Google scripts, such as gtm.js, directly from your first-party infrastructure instead of from Google's servers. This lets you serve data within a first-party context either through your tagging server or through a CDN.

Before you begin

This guide assumes that you have done the following:

To get started, pick how you want to serve your Google scripts.

Serve scripts with a CDN

If you have a CDN you can configure it to serve first-party scripts directly. This option requires that you setup same origin serving with your tagging server. Learn more about Google tag gateway with CDNs.

To setup Google tag gateway with server-side tagging you must configure two paths:

  1. Collection path (e.g. /metrics) --> Forwards events to your tagging server
  2. Script path (e.g. /scripts) --> Forwards first-party script requests to Google servers

Same-origin overview with server-side tagging.

Next steps

If you are using consent mode, you can set up region-specific tag behavior for even more control.