GA4 event mapping system
In the segment open-source analytics js they have this funny system for mapping event names over to the GA4 convention. This is because in GA4 they have adopted a new way of naming events that is quite different from prior GA versions and other packages people are sending events to.
It would be nice to have a system in place for this with this package. It may be that all the pieces are already there, so it may be just a matter of adding a bit of documentation explaining how to implement this kind of mapping, and filter out events that cannot be mapped over.
Not sure I follow. What kind of mapping system? Can you share some examples?
In GA4 they use these lower_snake_case event names, whereas in prior versions they used capitalized phrases. e.g. Page View -> page_view, Clicked Login Button -> clicked_login_button, etc..
In the segment analyticsjs they implemented it like this:
https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/google-analytics-4/lib/index.js#L27
See also https://support.google.com/analytics/answer/9267735?hl=en
https://support.google.com/analytics/topic/11091421
So for those of us sending events to multiple destinations where pretty much all of them are using capitalized phrases like Clicked Signup who want to also conform to GA4 norms like clicked_signup it would be nice to have a mapping.
It occurs to me this could be something generalized, maybe a way to "wrap" a plugin with a mapping of event names and data structure to customize for specific targets, or filter events altogether.
This may not be something that requires a code change - if there's a relatively simple way to have different event names / structures per backend, maybe just a note in the docs would work.