Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Default Initialize command for GA4 #27

Open
djswilly opened this issue Dec 15, 2021 · 0 comments
Open

Default Initialize command for GA4 #27

djswilly opened this issue Dec 15, 2021 · 0 comments

Comments

@djswilly
Copy link

djswilly commented Dec 15, 2021

Hi,

I am trying to use react-ga4 on a brand new site with GA4. I have no previous UA requirements. The current initialize command is not transparent enough and seems to default to legacy settings. For example, if I just call GA4.initialize("MY_MEASUREMENT_ID") the following command is sent:

Processing GTAG command: ["config", "MY_MEASUREMENT_ID", {send_page_view: false, custom_map: {dimension1: "dimension1", metric1: "metric1", ..., metric200: "metric200"}}]

There is no documentation on what legacyDimensionMetric does but if call GA4.initialize("MY_MEASUREMENT_ID", { legacyDimensionMetric: false }) then this command is sent:

Processing GTAG command: ["config", "MY_MEASUREMENT_ID", {send_page_view: false}]

So by default the current initialize command overrides the default send_page_view setting according to https://developers.google.com/analytics/devguides/collection/gtagjs/pages#manual_pageviews

The only way around this appears to be manually setting send_page_view to true by calling GA4.initialize("MY_MEASUREMENT_ID", { legacyDimensionMetric: false, gtagOptions: { send_page_view: true } }) which results in the following command being sent:

Processing GTAG command: ["config", "MY_MEASUREMENT_ID", {send_page_view: true}]

This works but it would be great if there was a separate initialize command or an option to initialize using the default command only with no additional config info as per Google documentation i.e. gtag('config', 'MY_MEASUREMENT_ID').

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant