Unverified Commit e71046b6 authored by Will Ashe's avatar Will Ashe Committed by GitHub

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: 's avatarJJ Kasper <jj@jjsweb.site>
parent f23f57f6
...@@ -61,7 +61,7 @@ export const sendGAEvent = (...args: Object[]) => { ...@@ -61,7 +61,7 @@ export const sendGAEvent = (...args: Object[]) => {
} }
if (window[currDataLayerName]) { if (window[currDataLayerName]) {
window[currDataLayerName].push(...args) window[currDataLayerName].push(args)
} else { } else {
console.warn( console.warn(
`@next/third-parties: GA dataLayer ${currDataLayerName} does not exist` `@next/third-parties: GA dataLayer ${currDataLayerName} does not exist`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment