Mirza Delic
Mirza Delic

Reputation: 4339

Google analytics Embeded api with out Oauth authorize

How can i use gapi.analytics.auth.authorize without button..

I need it for customers, to track visits on their subdomain, and I have my analytics code on page, so they can't use button to authorize, need without it, automatically. Any example?

Upvotes: 0

Views: 645

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116958

Your question isn't very clear it is hard to understand what you mean by Button.

I think you mean that you would like to select data from YOUR Google Analytics account and display it on YOUR website.

To do this you will need to use a service account as apposed to Oauth2 (Oauth2 would popup with a new window requesting access). When you create the service account in the Google developer console take the service account email address. Give it access at the ACCOUNT level in the Google analytics admin section. It must be the account level this will then give the service account access to read your Google analytics data.

Quota: I am not sure what you are extending to do here but remember you can only make 10000 requests per day against your Google Analytics profile. After that you are cut off there is no way to extend this number. So I advice you to save the data in the database someplace you shouldn't request the same data more then once.

Example: I suggest that you look for an example in what ever programing language you are intending to use. Again your question doesn't state anything about what language you will be using. Hello analytics API might be a good place to start but it depends upon the language the PHP one is way out of date I wouldn't bother with it. Also you cant use a service account with JavaScript so that one is out to.

Update figured out button

Embded api I think I have finally figured out what you mean by button. gapi.analytics.auth.authorize is used in the Google analytics embedded api. Which is JavaScript which it is not possible to use with a Service account. So the final answer to your question is

Answer: You cant remove the button from the Google Analytics Embded api the only way to login with JavaScript is to use Oauth2.
Advice: switch to PHP and use a service account to request data yourself. Or give each of your customers access to your Google analytics so they can login themselves.

Upvotes: 2

Related Questions