You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to conditionally only send a pageview event if the domain includes 'localhost:', but it seems the google tag automatically sends pageview events (or am I wrong about that)?
Is there something I'm missing that needs to be disabled to explicitly send pageview events, or is there a way to have an event include a parameter that indicates I'm using localhost or in a dev environment that I can created a filter with in GA4?
I dont want to create an internal traffic filter, or use devMode. I use many computers from multiple locations, so I'd like to just be able to either disable pageview events being sent from localhost or be able to create a custom filter that does that.
Initialize and log pageview
//Initialize GA4 if not already initialized and set that it is.
if (
!window.GA_ANALYTICS &&
googleAnalyticsTrackingCode
) {
initGA(googleAnalyticsTrackingCode);
window.GA_ANALYTICS = true;
//Log a pageview if google analytics is set and not local
if (!apiHost.includes('localhost:')) {
logPageView(window.location.pathname, document.title);
Router.events.on('routeChangeComplete', logPageView);
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I tried to conditionally only send a pageview event if the domain includes 'localhost:', but it seems the google tag automatically sends pageview events (or am I wrong about that)?
Is there something I'm missing that needs to be disabled to explicitly send pageview events, or is there a way to have an event include a parameter that indicates I'm using localhost or in a dev environment that I can created a filter with in GA4?
I dont want to create an internal traffic filter, or use devMode. I use many computers from multiple locations, so I'd like to just be able to either disable pageview events being sent from localhost or be able to create a custom filter that does that.
Initialize and log pageview
logPageView function
Beta Was this translation helpful? Give feedback.
All reactions