-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
Script (next/script)Related to Next.js Script Optimization.Related to Next.js Script Optimization.bugIssue was opened via the bug report template.Issue was opened via the bug report template.locked
Description
Link to the code that reproduces this issue
To Reproduce
Use GoogleTagManager component with dataLayer prop:
<GoogleTagManager dataLayer={{ websiteEnv: environment }} gtmId="12345" />Current vs. Expected behavior
In order to populate a variable to the dataLayer, it has to have an object pushed to it. Putting an array of strings into this prop doesn't do anything in GTM. Adding dataLayer={{websiteEnv:"dev"}} successfully populates the GTM variable, but is flagged by Typescript, because the props are typed as:
export type GTMParams = {
gtmId: string;
dataLayer?: string[];
dataLayerName?: string;
auth?: string;
preview?: string;
};I would expect GTMParams dataLayer prop type to be something like {[key: string]: string}
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:31 PST 2024; root:xnu-10063.101.15~2/RELEASE_X86_64
Binaries:
Node: 20.9.0
npm: 10.1.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 14.1.1
eslint-config-next: 14.1.1
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.3
Next.js Config:
output: standaloneWhich area(s) are affected? (Select all that apply)
App Router, Script optimization (next/script)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
Tested with @next/[email protected]
bstrawson, marlier, Manzurkds and octavioamu
Metadata
Metadata
Assignees
Labels
Script (next/script)Related to Next.js Script Optimization.Related to Next.js Script Optimization.bugIssue was opened via the bug report template.Issue was opened via the bug report template.locked