Ad

Is It Possible To Get Number Of Current Visits For Link From GA?

I have a dashboard, CMS, and customer wants to see current number of views for dozen of links. So, I was wondering if I can get that from Google Analytics. I send request with links, GA returns only number and every user must see these numbers, even though they are not admins on GA for this very page.

Thank you in advance.

Ad

Answer

The main issue you will have is that Google Analytics data is private user data. There for in order to see this data you must first login or be authenticated in some way. For what you are thinking of doing you should consider using a service account.

Think of a service account as a dummy user, it has its own google drive account google calendar account and also google analytics account. The great thing with service accounts is that they can be pre authorized to grant them access to data. By taking the service account email address and adding it as a user in the Google analytics admin section it will have access to that data without needing to be logged in.

Another thing you will need to consider is quota you can make max 10k requests a data against a single view with your application, this can not be increased so i recommend you cache this data somehow.

Ad
source: stackoverflow.com
Ad