reidark
reidark

Reputation: 910

Another account access my Analytics API

I want to build a dashboard to my clients access your respective website analytics. But, after some research, I'm stuck.

Let's imagine the scenario:

My Analytics Account:

  1. Client X - websitex.com
  2. Client Y - websitey.com

In my dashboard, when the cliente Y log in, the data (pageviews) of websitey.com is shown on graphics.

But, there's a way to do that? By the moment, the only thing i got is retrieve information for my logged account (my analytics ID), not the information about another account.

There's a way to use the Google API, or, I'll have a "separate database" to save data each website?

Sorry, I'm really lost at the moment.

Upvotes: 0

Views: 51

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32760

You can only view Google Analytics Accounts that you are authorized to view. For some reason this is a source of major confusion (seeing that your are not the first to ask), although it should be fairly self-evident.

If you want to see data from your clients account you have to ask your client to add your Google email to the GA account. If an email address is added to multiple accounts you can, via the API, choose between the accounts. Clientside authorization (OAuth2) will only work as long as somebody is logged in via a client application (usually a browser). The practial effect is that everybody who is authenticated via OAuth against Google will see only his own GA accounts, not other peoples data.

If you want a serverside application to pull data from various GA accounts you need a service account. But even the service account needs to be added to the GA accounts.

You can use the core reporting API, but the API will not give you access to accounts that you are not authorized to look at; your client needs to authorize you (or your applications service account).

Upvotes: 1

Related Questions