Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

reactjs - How can I set in code page ID to be detect in google analytics?

I need to give any page in my website a unique ID to be detected in google analytics or firebase analytics.

I will explain:

First of all, I'm developing using React.js.

I have lots of pages (routes) on my website. for example:

https://mywebsite.com/website1

https://mywebsite.com/website2

https://mywebsite.com/website3

In someday, I will change the route of the page and I want to keep detect the analytics data from the history using API.

Because of that, I need to set a constant ID for each page to be detected no matter what the route is.

question from:https://stackoverflow.com/questions/65934361/how-can-i-set-in-code-page-id-to-be-detect-in-google-analytics

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

1 Reply

0 votes
by (71.8m points)

You can do it by creating a datalayer variable - if you kept the datalayer the same on the page (even if the URL is different) you can send the variable as a custom dimension to Google Analytics. You can then report on that custom dimension as if it was a page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...