-
Notifications
You must be signed in to change notification settings - Fork 27.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@nextjs/third-party/google Custom Events Don't Register When Using sendGAEvent()
#61703
Comments
In my case the /collect request is not even sent to ga. expected behavior:
|
I encountered this as well today. Behaves exactly the same as described here in the issue for me. |
Holy thank you for posting this. I've been going crazy trying to use this package to send custom events. |
same thing for me, default events are working fine (scroll, view, etc...) but custom ones are not ! |
Running into the same issue. It appears to be due to how arguments are being read and passed to the |
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](#61703) Co-authored-by: JJ Kasper <jj@jjsweb.site>
I believe the merged code does not fix the issue as it still can be seen with "@next/third-parties": "^14.1.1-canary.58". As per @willashe's comment, seems like Left a comment in the PR: https://github.com/vercel/next.js/pull/62065/files/4572a3bbd70c5c42fcf0c70bc90b7d936605a702#r1493345098 |
The recently merged PR - #62065, doesn't seem to fix the issue. As per the comment this seems to be related to `dataLayer` that does not like working with Arrays, but works with [arguments object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments). Also, when using window.gtag(...) an Arguments() is pushed instead of Array(). Fixes #61703
Yea disappointing that my changes were reverted and merged, the resulting PR didn't fix anything. Thank you for picking this back up anyway. |
Hi guys, I am a bit confused now what the latest status is. Can you confirm that the second merge ("Fix sendGAEvent function (for real?)") really solves the issue? I built my app using the 14.1.1-canary.61 version but the events still don't show up in Google Analytics. Also not in the real time view. Maybe I understood something wrong and another fix is needed first, then any clarification would be much appreciated. Thank you. |
Hey @felix-mittermeier, just gave it a run again and it seems to be working. Note that you will now need to use it as
as mentioned in #62065 (comment) |
That was indeed the issue. Thanks a lot for the help |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/AbdelrahmanSadat/ga-issue
To Reproduce
<GoogleAnalytics>
component in the app's layout.sendGAEvent({event: "custom_event", value: 'value'})
on any client component.custom_event
in GACurrent vs. Expected behavior
Expected the
custom_event
to be reported in GA.Provide environment information
Which area(s) are affected? (Select all that apply)
Script optimization (next/script)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Not really sure how I can provide a reproduction for this since it would also require access to a Google Analytics dashboard. But long story short, I tried
@nextjs/third-parties/google
instead of using a<Script>
, and while that part works and normal events fire, manually firing custom events (or predefined events) using the library'sSendGAEvent()
doesn't register on the dashboard.I removed any use of
SendGAEvent()
and instead used(window as any).gtag("event", "custome_event", {value: "value"})
, and my custom_event was firing and showing on the dashboard, so that rules out any issue in my GA setup.The text was updated successfully, but these errors were encountered: