Analycis code updated...

1,769 views
Skip to first unread message

Frank Mantek

unread,
May 26, 2009, 9:46:06 AM5/26/09
to gdata-dotnet-...@googlegroups.com
I just updated the analytics code for the .NET library, and i think it
is functional complete now (pending further feedback).

You can get this here:

http://code.google.com/p/google-gdata/source/browse/

If you sync to the depot, you get new dlls etc. The following code
snippets should illustrate what you can do:


RequestSetting settings = new RequestSettings("youapp", "user", "pwd");
settings.AutoPaging = true;

AnalyticsRequest r = new AnalyticsRequest(settings);

Feed<Account> accounts = r.GetAccounts();
string id = "";

foreach (Account a in accounts.Entries)
{
Console.WriteLine(a.AccountName);
Console.WriteLine(a.AccountId);
// remember one id
id = a.AccountId;
}

DateTime endDate = DateTime.Now;
DateTime startDate = endDate.AddDays(-2);

DataQuery q = new DataQuery(id, startDate, endDate);

Dataset set = r.GetData(q);

Console.WriteLine(set.Aggregates.Metrics[0].IntegerValue);
Console.WriteLine(set.Aggregates.Metrics[0].ConfidenceInterval);
Console.WriteLine(set.DataSource.TableName);

foreach (Data d in set.Entries)
{
Console.WriteLine(d.Title);
Console.WriteLine(d.Metrics[0].Value);
}


Note, the above code is written in that email, so i am not
guaranteeing a cut/copy/paste working sample here...

I would love some feedback, especially for those with working
analytics accounts/projects to give this a spin.


Frank Mantek
Google

Frank Mantek

unread,
May 29, 2009, 8:53:44 AM5/29/09
to Google Data APIs .NET Client Library
This code just got some bugfixes in the repository. Please give it
another go.

Frank Mantek
Google

Theis Boddum

unread,
Jun 22, 2009, 3:54:50 AM6/22/09
to Google Data APIs .NET Client Library
hi,

When will the analytics library be available in the Google Data API
for .NET

Best regards
TB
> > Google- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -

Frank Mantek

unread,
Jun 22, 2009, 8:22:07 AM6/22/09
to gdata-dotnet-...@googlegroups.com
It is - assuming you want to sync to the repository and just use the
DLLs there. If you are waiting for an official setup, this will be a
while as i want to add contacts v3 and probably the maps api to that
as well.

Creating a setup has a large overhead - it indicates testing, several
platforms, documentation etc.... I rather do this only after a
sufficient amount of changes have happened in the codebase.

Frank Mantek
Google

normrider

unread,
Jul 2, 2009, 12:51:13 PM7/2/09
to Google Data APIs .NET Client Library
One quick note for the data query to work I believe you would need to
make the id = a.TableId instead of a.AccountID since the data query
needs a profile ID.

That said I'm not able to get data queries to work in analytics. I
always get a 400 bad request message.

I'm able to pull my analytics account information. I can never get
the data queries to work.

I'm basically using a similar example to your example above, but I'm
just replacing the AccountID with the TableID since it has the profile
ID in the correct format ga:0000000.

From what I can tell the query that is being sent is

https://www.google.com/analytics/feeds/data?ids=ga:000000000&start-date=2009-06-20&end-date=2009-06-29

I believe there is some issue with the encoding of the colon, but I'm
not sure. Note I've changed my profile ID since this is a public
forum

Craig Norman
Message has been deleted

normrider

unread,
Jul 2, 2009, 1:33:43 PM7/2/09
to Google Data APIs .NET Client Library
I found that the dimensions and metrics I were using were incorrect so
that is why I got the 400 Bad Request errors.


On Jul 2, 10:51 am, normrider <craigand...@gmail.com> wrote:
> One quick note for the data query to work I believe you would need to
> make the id = a.TableId instead of a.AccountID since the data query
> needs a profile ID.
>
> That said I'm not able to get data queries to work in analytics.  I
> always get a 400 bad request message.
>
> I'm able to pull my analytics account information.  I can never get
> the data queries to work.
>
> I'm basically using a similar example to your example above, but I'm
> just replacing the AccountID with the TableID since it has the profile
> ID in the correct format ga:0000000.
>
> From what I can tell the query that is being sent is
>
> https://www.google.com/analytics/feeds/data?ids=ga:000000000&start-da...

Frank Mantek

unread,
Jul 3, 2009, 3:19:54 AM7/3/09
to gdata-dotnet-...@googlegroups.com
Just to clarify, everything works for you now?

Frank

normrider

unread,
Jul 3, 2009, 11:00:42 AM7/3/09
to Google Data APIs .NET Client Library
It does work for me now. The default query with a profile ID, a start
date and an end date did not pull any data for me.

However I'm not able to use the API for .Net. The reason why is
because I'm trying to use oAuth with a Token and a Token Secret. I
know that oAuth is included in the libraries but I don't believe I can
use a Token with it. I believe it only supports a consumer and
consumer secret.

Do you know of other examples where people have integrated "three
legged" oAuth into the Google API with .Net?

Basically I would like to use this .Net analytics API to generate the
query or the initial URL. Pass that URL into my oAuth
implementation. Then use the .Net analytics API to parse the
response. The response I receive from Google Analytics is in a
string. I would like to convert that into a Google Analytics Dataset
object.

Do you know of an example that implements something like this?

Duncan

unread,
Jul 15, 2009, 4:36:31 AM7/15/09
to Google Data APIs .NET Client Library
I would also be looking for either oAuth or AuthSub authentication
methods, mainly because users of our software would rather submit
credentials straight to Google and not our third-party application.

Thanks
Duncan

Frank Mantek

unread,
Jul 15, 2009, 12:11:04 PM7/15/09
to gdata-dotnet-...@googlegroups.com
Authsub and client token oAuth are both supported.

Frank Mantek
Google

c.ro...@gmail.com

unread,
Jul 16, 2009, 6:01:01 AM7/16/09
to Google Data APIs .NET Client Library
This is a great API.
I'm working on the analytics code and i found a bug (I think)

The default accounttype does not work:
AccountTypeDefault = "HOSTED_OR_GOOGLE"

If I change the accounttype like this then it works:
GDataGAuthRequestFactory factory = (GDataGAuthRequestFactory)
service.RequestFactory;
factory.AccountType = "GOOGLE_OR_HOSTED";

regards, Corné
> > Duncan- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Frank Mantek

unread,
Jul 20, 2009, 4:04:07 AM7/20/09
to gdata-dotnet-...@googlegroups.com
This is actually a bug in the google authentication services, which
depends on your account credentials. The default HOSTED_OR_GOOGLE
seems to fail for some accounts, those account would work if you ask
for a "GOOGLE" account. Your string seems to be treated by the
authentication service as just "GOOGLE", and hence it works.

Feel free to file a bug against the service here:

http://code.google.com/p/gdata-issues/

Frank Mantek
Google
Reply all
Reply to author
Forward
0 new messages