1
votes

Reading Google Analytics API docs is like diving into Mariana Trench... so hoping to get some help here.

I have a website that users will visit one page per visit (most of the time). I've placed google analytics script on each page (can view reports in my GA account) and now want to write a "reporting page" on which to display information about "per page usage":

page1: 100 visitors, countries, OSes, ...
page2: 125 visitors, countries, OSes, ...

I want to get this info from API.

Could some one please point me to the right pages of the docs, from the very beginning?

For I can't understand even why I should use 2-step OAuth authorization there (or shouldn't I?) - since I'm writing this report for my own site on which I have already placed google scripts thus authorizing everything.

Thank you.

1
Yes you can get result like that. use query explorer ga-dev-tools.appspot.com/explorer and filter - Kamran Shahid
Hi, thanks for the reply, this tool is great! Sorry, maybe I was not clear enough, but I want this "reporting page" to be in general acccess, i.e. anyone could go to mysite.com/page1/statistics and get statistics on the usage of mysite.com/page1 However now it asks for auth credential... How can I login on server-side? - xaxa
In which language you are making your application. I can do this type of thing in a asp.net application.You have to learn getting this statistics data via .net (or language of your choice if it is supported by GA) - Kamran Shahid
In Javascript (Node.js), can you post a piece of your authorization code? - xaxa
@KamranShahid, please post your code. If it is in .Net, it's OK, because all I need is a single POST request, I guess... Or guide me to the page in GA API docs. Thank you - xaxa

1 Answers

1
votes

What i am thinking is that I could have a Webapplication with your pages listed. Web application itself is authenticating and querying the result on when user try to find statistics of particular page. You should follow 1. Register Service account and get authentication key file 2. Register email account viewed in along clientid email a screen in google analytic users as admin level user 3. Use ga-dev-tools.appspot.com/explorer for query building 4.Implemenation needs a) First Authenticate with the key b) Get profile id and pass it to the fetching method c) Fetch data of the query