Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

reactjs - Why does putting a GA4 script in the index.html give correct page events?

I was hoping to better understand how the new Google Analytics 4 works with React.

I thought that it'd require wrapping around a Route component but it seems as though pasting the script tag generated by Google into the index.html is enough to get it to send events which includes showing all the page views, etc. on the GA site.

If anyone could explain why that works or how it could break, that would be greatly appreciated. From everything I've seen and limited experience with the old UA system it appears that it shouldn't.

It feels like there isn't a lot of information out there due to how new the system is and Google's docs on it aren't great.

Thanks!

question from:https://stackoverflow.com/questions/66056206/why-does-putting-a-ga4-script-in-the-index-html-give-correct-page-events

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...