Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:09:55+00:00 2026-06-11T19:09:55+00:00

i want to access Google analytic data and i got samples from Google data

  • 0

i want to access Google analytic data and i got samples from Google data API SDK. but these coding does not working and throws exception

Execution of request failed: https://www.google.com/analytics/feeds/accounts/default

so i found the reason for this is Google updated it’s to v3.0. i searched updated coding for the C#, but i couldn’t find solution for this.

i have same problem as this, but with C#.
Exception thrown when using GData .NET Analytics API

i tried coding with doing changes as follows as it says in Google developer – https://developers.google.com/analytics/resources/articles/gdata-migration-guide#appendix_a

string userName = this.Username.Text;
string passWord = this.Password.Text;

AnalyticsService service = new AnalyticsService("AnalyticsSampleApp");
service.setUserCredentials(userName, passWord);
string googleAccountWebId = "AIXXXXXXXXXXXXXXXXXXXXXXXXXXX";
string profileFeedUrl = "https://www.googleapis.com/analytics/v2.4/data?key=" + googleAccountWebId;

DataQuery query2 = new DataQuery(profileFeedUrl);
query2.Ids = "12345678";
query2.Metrics = "ga:visits";
query2.Sort = "ga:visits";
query2.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("2011-08-01");
query2.GAEndDate = DateTime.Now.ToString("2013-09-01");
query2.StartIndex = 1;


DataFeed data = service.Query(query2);


foreach (DataEntry entry in data.Entries)
{
    string st=entry.Metrics[0].Value;       
}

but even i change this it throws exception in

DataFeed data = service.Query(query2);

this line. exception is as follows:

Execution of request failed: https://www.googleapis.com/analytics/v2.4/data?key=AIXXXXXXXXXXXXXXXXXXXXXX-8&start-index=1&end-date=2013-09-01&ids=12345678&metrics=ga:visits&sort=ga:visits&start-date=2011-08-01

i’m using following DLL

Google.GData.Analytics.dll
Google.GData.Client.dll
Google.GData.Extensions.dll

My Questions :

  1. how can i correct this error?

  2. how can i access Google analytic data? is this correct? or else what is the way to doing it??
    for a example i want to get available ProfileId and their values. (Title and Page views)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:09:56+00:00Added an answer on June 11, 2026 at 7:09 pm

    Analytics Account:

    I am assuming you have an analytics account already if you don’t then create one, and sign up your domain here:
    http://www.google.com/intl/en/analytics/

    To get your API Key do this:

    Follow the instructions on https://developers.google.com/analytics/resources/articles/gdata-migration-guide (Create a Project in the Google APIs Console) to generate your key Once you have it set it as part of the querystring to request to Google Analytics service, in this case:
    YourAPIkEStringabcdefghijklmno

    To get the profileId (Ids on the code) you should do this:

    Log into your analytics account, select the desired domain on your list (blue link) click on the administrator button and on the profiles tab find the profile
    configuration subtab, right there you will find the profile id in this case the eight characters long id:
    12345678

    Here you have some C# code to help you getting the number of visits for that 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";
    
        //You were setting 2013-09-01 and thats an invalid date because it hasn't been reached yet, be sure you set valid dates
        //For start date is better to place an aprox date when you registered the domain on Google Analytics for example January 2nd 2012, for an end date the actual date is enough, no need to go further
        query1.GAStartDate = new DateTime(2012, 1, 2).ToString("yyyy-MM-dd"); 
        query1.GAEndDate = DateTime.Now.ToString("yyyy-MM-dd");
        query1.StartIndex = 1;        
    
        DataFeed dataFeedVisits = service.Query(query1);
    
        foreach (DataEntry entry in dataFeedVisits.Entries)
        {
            string st = entry.Title.Text;
            string ss = entry.Metrics[0].Value;
            visits = ss;
        }
    
        return visits;
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) 
        {
            Response.Write("Visits:" + this.VisitsNumber());
        }
    }
    

    Since the 2.4 API is not so flexible anymore, I have another post here hacking it to get the profile Id:
    Getting an specific ProfileId from registered Accounts using GData .NET Analytics API 2.4 if you need to convert the code to C# you can use the Telerik converter: http://converter.telerik.com/

    I think this suffice to use the 2.4 API. If you need extra help let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to access some data from Google maps. the only way possible is
I want to access google AuditService api from google app engine application.user is already
I am using the Google API Client to access Google Analytics. I want to
I want to access google map api for reverse geocoding. I access the url
I am loading LessCSS from Google Code with jQuery , and want to access
I want to access/add/read etc google calender from my Android program. I have tried
I want to access camera to record video to upload, but have come across
I want to access a static variable from a static method: #!/usr/bin/env python class
i want to access a integer and a string from a class to all
I'm using jquery, and I want to access some data on my server using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.