codler / react-ga4

React Google Analytics 4
https://www.npmjs.com/package/react-ga4
274 stars 35 forks source link

[Request] Support options.titleCase #39

Open fehbari opened 1 year ago

fehbari commented 1 year ago

The original react-ga support a titleCase parameter when initializing. This doesn't seem to be present here. All my events are sent with a capitalized first letter.

e.g. this_event ends up as This_event in Google Analytics.

vabadio commented 1 year ago

I'm having the same issue. Is there a fix for this as of now?

fehbari commented 1 year ago

@vabadio The way I'm working around it is by using the alternative call with event name + parameters object.

ReactGA.event('my_event_action', {
    event_category: 'my_category',
    event_label: 'my_label',
    value: 'my_value',
    non_interaction: true,
    ...otherParams, // optional
});

Everything is sent in the desired case that way.

With this call you can also send custom dimensions alongside the event (the ...otherParams part).

vabadio commented 1 year ago

@fehbari thank you so much!

7assenTlili commented 10 months ago

Created a PR to support this either when creating ga4 instance or when calling the event() method