onehilltech / ember-cli-google

a collection of Google services as an Ember CLI add-on
Apache License 2.0
12 stars 3 forks source link

Bug fix: `gtag.event()` syntax #11

Closed fdeters closed 2 months ago

fdeters commented 2 months ago

This PR fixes a bug where the gtag service's event() method sends the event to the window.dataLayer with incorrect syntax. This bug prevents GA4 from receiving any event sent via gtag.event().

I noticed this bug first on my own, then saw it corroborated by @romgere in #8. This comment in that thread matches my experience, and my proposed solution.

Here's the syntax that should be used to send events, via the API documentation:

gtag('event', '<event_name>', {<event_params>});

If accepted, this 1-line change will close #8 and make it possible to send events via this package. Best of all, the change doesn't break existing calls to gtag.event(), it just makes those calls actually work.

Thanks for making this available! I hope this contribution helps.

hilljh82 commented 2 months ago

Thank you for this fix!

fdeters commented 2 months ago

@hilljh82 thanks for merging this and #10! For some reason, I'm not seeing the new commits showing up on master. Do you know what's up with that?