2 weeks ago
I have a SPA react based app and I trigger pageview upon navigation through the app when url changes. I have added the GA tag. GA pageview locaiton field is always populated with the value of the url of the first page on which the user lands and not the subsequent urls. How may I go about changing the location?
a week ago - last edited a week ago by kathleen_jo
You can overwrite the location parameter for the Google call by mapping a variable to the "location" destination in your Google Analytics tag mapping toolbox. This variable should be dynamically updated with the value in your utag.link or utag.view call for all subsequent (not initial pageview) events for your REACT setup. Also, you will want to make sure that you have the "clear vars" setting within the tag's configurations set to "on" to make sure that all variables set with the "SET.xxxx" method from Google are cleared out.
Hope that helps!
Monday - last edited Monday by kathleen_jo
@momen, as we are using Tealium on a React based website as well, I want to advise against setting the location parameter but instead to set the page parameter on every view. This is also the official advise from Google (https://developers.google.com/analytics/devguides/
The reason for this is that setting the location parameter risks to lose referral information, which may cause a session restart in Google Analytics. Simon Ahavas blog has some background information on this topic (https://www.simoahava.com/gtm-tips/fix-rogue-refer