Monday, December 22, 2014

Fetch google analytics statistics in C#

Google Analytics Reporting API
The reporting API is a simple yet powerful API (application programming interface) that allows the developers to retrieve the gathered data from Google Analytics. In order to retrieve the statistics, some have to be gathered first. Therefore, there is one important prerequisite in order to use the API. You have to have a Google account and a website with the tracking code. I assume you already know how to generate the JavaScript tracking code and insert it into your website.


Enabling the API Access

There are two different options how to fetch the data. The first option is the Simple API access that doesn’t allow accessing any private user data, so it is not sufficient for our purpose. The second approach is the Authorized API access (OAuth 2.0) that allows us to access private user data, so we are going to stick with it.

In order to rely on OAuth 2.0, our application must be authenticated and the user must grant access to it. To do so, several steps have to be taken.

First, we have to log on to the Google Developers Console with our Google account and create a new project. 

No comments:

Post a Comment