Skip to content
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

Is it possible to set "send_page_view" to "false" with this "react-ga4" ? #72

Open
sin-to-jin opened this issue Apr 9, 2024 · 9 comments

Comments

@sin-to-jin
Copy link

sin-to-jin commented Apr 9, 2024

What

This time, I wrote the following pattern code to avoid sending "page_view", but all "page_view" were sent to GA4, so I made this issue. Is there any solution?
If anyone knows of any solutions or workarounds, it would be appreciated.

ReactGA.initialize([
  {
    trackingId: "xxxxxxx",
    gaOptions: { send_page_view: false },
  }
])

Or,

ReactGA.ga('config', "xxxxxxx", { send_page_view: false })

Or,

ReactGA.initialize([
  {
    trackingId: "xxxxxxx",
  }
])
ReactGA.send({ send_page_view: false })

Refference

@EPGDigital-MW
Copy link

From my testing this appears to be working, I manually trigger the first page view in my app

ReactGA.initialize([{
    trackingId: TRACKING_ID,
    gaOptions: {
        send_page_view: false,
    }
}]);

@EPGDigital-MW
Copy link

EPGDigital-MW commented May 28, 2024

Apologies, after more testing that wasn't working!

This appears to be working:

ReactGA.initialize(TRACKING_ID, {
    gaOptions: {
        send_page_view: false,
    }
});

This results in:

{
	0: "config",
	1: "TRACKING_ID",
	2: {
		send_page_view: false
	}
}

@sin-to-jin
Copy link
Author

@EPGDigital-MW Thanks for the advice, I'll give it a shot! I'll post more on this ish if I find anything else.

@sin-to-jin
Copy link
Author

I tried this approach, but it seems that page_view is still being sent in my environment...

@soapraj
Copy link

soapraj commented Jun 5, 2024

+1 I am facing the same issue as above. page_view events are sent even when send_page_view is set to false in the initialize call

Edit: This example works for me

ReactGA.initialize(TRACKING_ID, { gaOptions: { send_page_view: false, } });

In my case turning off "Page changes based on browser history events" in the GA4 admin and setting the send_page_view stopped all the page_view events from being collected automatically.

@sin-to-jin
Copy link
Author

sin-to-jin commented Jun 6, 2024

Thanks for the advice!

ReactGA.initialize(TRACKING_ID, {
    gaOptions: {
        send_page_view: false,
    }
});

It still doesn't seem to work...

@EPGDigital-MW
Copy link

In my case turning off "Page changes based on browser history events" in the GA4 admin and setting the send_page_view stopped all the page_view events from being collected automatically.

I've disabled this, then also disabled enhanced measurement as I don't need any other events, everything is triggered within the app manually.

@sin-to-jin
Copy link
Author

I see, so you are saying that the GA side of the configuration needs to be changed. I'll have to check it out.

@mleister97
Copy link

Any updates?

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

No branches or pull requests

4 participants