Having server-side GTM container enabled a number of new tracking capabilities. One of the key advantage is ability to load the GTM.js and gtag from a first party domain.

When enabled the GTM javascript is not loaded from the standard URL which will be easily identified as tracking script:

https://www.googletagmanager.com/gtm.js

But will be loaded from custom subdomain:

https://metrics.yourshop.com/gtm.js

This keeps all the traffic within first party realm and will address a notification that appear in server-side GTM workspace:

![](https://s3.amazonaws.com/helpscout.net/docs/assets/602051cd3ea803634aef8832/images/687f6921965d8266feba1e57/file-hP4pAKDnDO.png)
Serve Google scripts from your tagging serverYou can now serve all Google scripts (gtag.js, gtm.js, etc.) with the Web container client.

Configure GTM containers

The tricky part about this setup is that two GTM containers are involved:

In order to make the server GTM container able to server gtm.js file a Google Tag Manager: Web Container client needs to be added to the GTM workspace and published.

You can learn more details in our dedicated guide:

How-to: Serve GTM Web container from Server container?

Pass gtmScriptUrl prop

Now that we have GTM server container running at desired URL (subdomain of the main website) and the web client deployed we need to use @next/third-parties/google and GoogleTagManager component passing not only the gtmId , but also gtmScriptUrl .

Example

import { GoogleTagManager } from '@next/third-parties/google'

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    
      
      {children}
    
  )
}