From e87d9e62520ca74b7a1cd1d5698817a010e34345 Mon Sep 17 00:00:00 2001 From: Ian Marlier Date: Wed, 29 May 2024 11:52:23 -0400 Subject: [PATCH 1/2] GTM dataLayer parameter should take an object, not an array of strings --- packages/third-parties/src/types/google.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/third-parties/src/types/google.ts b/packages/third-parties/src/types/google.ts index 30a4e9f28a464..aaae926d2a5c6 100644 --- a/packages/third-parties/src/types/google.ts +++ b/packages/third-parties/src/types/google.ts @@ -5,9 +5,16 @@ declare global { } } +type JSONValue = + | string + | number + | boolean + | JSONValue[] + | { [key: string]: JSONValue } + export type GTMParams = { gtmId: string - dataLayer?: string[] + dataLayer?: { [key: string]: JSONValue } dataLayerName?: string auth?: string preview?: string From 16687b96ac0b9b8d30483e08fcfc0392fd61db3c Mon Sep 17 00:00:00 2001 From: Ian Marlier Date: Wed, 29 May 2024 13:39:17 -0400 Subject: [PATCH 2/2] update docs to give correct parameter type --- .../06-optimizing/12-third-party-libraries.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 dbf25dd1a79b8..c169e1a01b8b3 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 @@ -168,13 +168,13 @@ different variables and events that can be passed into the function. Options to pass to the Google Tag Manager. For a full list of options, read the [Google Tag Manager docs](https://developers.google.com/tag-platform/tag-manager/datalayer). -| Name | Type | Description | -| --------------- | -------- | ------------------------------------------------------------------------------- | -| `gtmId` | Required | Your GTM container ID. Usually starts with `GTM-`. | -| `dataLayer` | Optional | Data layer array to instantiate the container with. Defaults to an empty array. | -| `dataLayerName` | Optional | Name of the data layer. Defaults to `dataLayer`. | -| `auth` | Optional | Value of authentication parameter (`gtm_auth`) for environment snippets. | -| `preview` | Optional | Value of preview parameter (`gtm_preview`) for environment snippets. | +| Name | Type | Description | +| --------------- | -------- | --------------------------------------------------------------------------------- | +| `gtmId` | Required | Your GTM container ID. Usually starts with `GTM-`. | +| `dataLayer` | Optional | Data layer object to instantiate the container with. Defaults to an empty object. | +| `dataLayerName` | Optional | Name of the data layer. Defaults to `dataLayer`. | +| `auth` | Optional | Value of authentication parameter (`gtm_auth`) for environment snippets. | +| `preview` | Optional | Value of preview parameter (`gtm_preview`) for environment snippets. | ### Google Analytics