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
183 views
in Technique[技术] by (71.8m points)

Add view count to webpage from Google Analytics

I am trying to create a view count feature for a webpage. To do this, I created a new property and generated a tracking id from Google Analytics.

Is there a way I can use the page vists data from there and display it on the same page that I am tracking?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

You can, but since GA APIs are authenticated, you will need to handle that authentication one way or another.

You have basically 3 options:

serverAuth.access_token Type: string

If you already have a valid access token, you can pass it to the authorize method directly and the user will not be prompted to authorize. For details on how to retrieve an access token, see the OAuth 2.0 documentation.

Note: you probably don't have to do step 2 if you're careful, and can publish as CSV your sheet from steo 1 directly: since it's a CSV export, people cannot get to the original spreadsheet so no security risk. But just to be on the safe side (eg you could publish the whole spreadsheet by mistake), I would do step 2.

As for which middleware you want to use, there's probably an infinite number of options :)


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

...