Skip to content

Commit

Permalink
Fix sendGAEvent function (vercel#62065)
Browse files Browse the repository at this point in the history
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](vercel#61703)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
willashe and ijjk authored Feb 16, 2024
1 parent f23f57f commit e71046b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/third-parties/src/google/ga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit e71046b

Please sign in to comment.