简体   繁体   中英

Pulling in Google Analytics data without authenticating as a user

I would like to pull in data from Google analytics for visits per day over the last month and show it on the dashboard of the CMS I am building.

The problem is it seems you have to use Oauth2. I don't want to authenticate as a user as I want the information available to all users logging in. Whats the best way to accomplish what I am after?

I only require read access and only need simple stats.

I may also have multiple versions of this CMS running, would I need to register each one in the Google API console?

The problem is it seems you have to use Oauth2. I don't want to authenticate as a user as I want the information available to all users logging in. Whats the best way to accomplish what I am after?

The OAuth2 method, is mandatory. You cannot fetch the data if you don't use the authentication because the analytics data are privates.

You can write a PHP script which use the Google PHP API client to fetch the data from Google Analytics. The PHP script will authenticate for you and it will get all the analytics data you need (I suggest you to have a look at Core Reporting APIs ). Then, the results can be showed to logged users or to the public. The data sharing is under your control.

I may also have multiple versions of this CMS running, would I need to register each one in the Google API console?

No

try searching for google api service accounts on google or in this site. it is now available for analytics service too. Just remember to use the latest version of the api client library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM