Google Analytics Account:
I assume that you already have an analytic account, if you do not create one, and register your domain here: http://www.google.com/intl/en/analytics/
To get your API key, follow these steps:
Follow the instructions https://developers.google.com/analytics/resources/articles/gdata-migration-guide (create a project in the Google API console) to generate your key. When you install it as part of a request that requests Google Analytics, in this case: YourAPIkEStringabcdefghijklmno
To get the profileId (code ids), you must do the following:
Log in to your analytics account, select the domain you need in the list (blue link), click the "Admin" button and on the "Profile" tab find the config subtab profile, there you will find the profile identifier in this case eight characters long: 12345678
Here you have the C # code that will help you get the number of visits for this Id:
public string VisitsNumber() { string visits = string.Empty; string username = "youremailuser@domain.com"; string pass = "yourpassword"; string gkey = "?key=YourAPIkEYYourAPIkEYYourAPIkEYYourAPIkE"; string dataFeedUrl = "https://www.google.com/analytics/feeds/data" + gkey; string accountFeedUrl = "https://www.googleapis.com/analytics/v2.4/management/accounts" + gkey; AnalyticsService service = new AnalyticsService("WebApp"); service.setUserCredentials(username, pass); DataQuery query1 = new DataQuery(dataFeedUrl); query1.Ids = "ga:12345678"; query1.Metrics = "ga:visits"; query1.Sort = "ga:visits";
Since API 2.4 is not so flexible anymore, I have another entry that hacks it to get the profile ID: Getting a specific profile from registered accounts using GData.NET Analytics API 2.4 , if you need to convert the code to C #, you can use Telerik converter: http://converter.telerik.com/
I think this is enough to use API 2.4. If you need more help let me know.
CoderRoller Sep 24 2018-12-12T00: 00Z
source share