diff --git a/docs/02-app/01-building-your-application/06-optimizing/12-third-party-libraries.mdx b/docs/02-app/01-building-your-application/06-optimizing/12-third-party-libraries.mdx
index ab7f5b9ef589e..7188b386fb436 100644
--- a/docs/02-app/01-building-your-application/06-optimizing/12-third-party-libraries.mdx
+++ b/docs/02-app/01-building-your-application/06-optimizing/12-third-party-libraries.mdx
@@ -116,6 +116,16 @@ export default function Page() {
```
+#### Using a custom server URL
+
+If you have a server-side tag manager deployment, you can customize the URL by passing in a `url` parameter. The component uses `https://www.googletagamanager.com` by default.
+
+```jsx
+import { GoogleTagManager } from '@next/third-parties/google'
+
+
+}
+```
#### Sending Events
diff --git a/packages/third-parties/src/google/gtm.tsx b/packages/third-parties/src/google/gtm.tsx
index 1203525cc1e34..6296a7356a489 100644
--- a/packages/third-parties/src/google/gtm.tsx
+++ b/packages/third-parties/src/google/gtm.tsx
@@ -8,7 +8,7 @@ import type { GTMParams } from '../types/google'
let currDataLayerName: string | undefined = undefined
export function GoogleTagManager(props: GTMParams) {
- const { gtmId, dataLayerName = 'dataLayer', auth, preview, dataLayer } = props
+ const { gtmId, dataLayerName = 'dataLayer', auth, preview, dataLayer, url } = props
if (currDataLayerName === undefined) {
currDataLayerName = dataLayerName
@@ -17,7 +17,7 @@ export function GoogleTagManager(props: GTMParams) {
const gtmLayer = dataLayerName !== 'dataLayer' ? `&l=${dataLayerName}` : ''
const gtmAuth = auth ? `>m_auth=${auth}` : ''
const gtmPreview = preview ? `>m_preview=${preview}>m_cookies_win=x` : ''
-
+ const gtmUrl = url ? url : 'https://www.googletagmanager.com'
useEffect(() => {
// performance.mark is being used as a feature use signal. While it is traditionally used for performance
// benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
@@ -47,7 +47,7 @@ export function GoogleTagManager(props: GTMParams) {
>
)
diff --git a/packages/third-parties/src/types/google.ts b/packages/third-parties/src/types/google.ts
index 30a4e9f28a464..8216ef3c664e0 100644
--- a/packages/third-parties/src/types/google.ts
+++ b/packages/third-parties/src/types/google.ts
@@ -11,6 +11,7 @@ export type GTMParams = {
dataLayerName?: string
auth?: string
preview?: string
+ url?: string
}
export type GAParams = {