From e71046b61077d1e70ef3d2e64fdd34fad2545d32 Mon Sep 17 00:00:00 2001 From: Will Ashe Date: Fri, 16 Feb 2024 12:56:19 -0600 Subject: [PATCH] Fix sendGAEvent function (#62065) Previous implementation of `sendGAEvent` was pushing arguments to `dataLayer` via rest parameter syntax, resulting in an actual array, which GA doesn't seem to process correctly (resulting in the event not showing up in GA reports). This PR refactors it to a vanilla JS function passing data via the `arguments` array-like object, which is able to be processed correctly and results in the event showing up as expected. fixes [61703](https://github.com/vercel/next.js/issues/61703) Co-authored-by: JJ Kasper --- packages/third-parties/src/google/ga.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/third-parties/src/google/ga.tsx b/packages/third-parties/src/google/ga.tsx index 448325a4aeb59..d2f0779e6e4cc 100644 --- a/packages/third-parties/src/google/ga.tsx +++ b/packages/third-parties/src/google/ga.tsx @@ -61,7 +61,7 @@ export const sendGAEvent = (...args: Object[]) => { } if (window[currDataLayerName]) { - window[currDataLayerName].push(...args) + window[currDataLayerName].push(args) } else { console.warn( `@next/third-parties: GA dataLayer ${currDataLayerName} does not exist`