Greg Robbins
unread,May 22, 2009, 4:29:50 PM5/22/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gdata-objec...@googlegroups.com
I've checked in classes to support the Google Analytics Data API to the top-of-trunk in the Objective-C library's svn repository.
There is currently no sample app for the new classes, though the following snippets show how to fetch the account and data feeds.
Note that the Analytics API feeds do not yet include "kind" category elements indicating the class for each type of feed and entry. So rather than use the normal fetch calls in the GDataServiceGoogleAnalytics class, currently the superclass's "fetchAuthenticated..." calls must be used instead, as those take the class of the created object as an argument. The snippets below demonstrate this.
// fetch the feed of account entries for the authenticated user
NSURL *feedURL = [NSURL URLWithString:kGDataGoogleAnalyticsDefaultAccountFeed];
GDataServiceGoogleAnalytics *service = [self analyticsService];
GDataServiceTicket *ticket;
ticket = [service fetchAuthenticatedFeedWithURL:feedURL
feedClass:[GDataFeedAnalyticsAccount class]
delegate:self
didFinishSelector:@selector(accountsTicket:finishedWithFeed:)
didFailSelector:@selector(accountsTicket:failedWithError:)];
Once the accounts feed is fetched, the data feed for an account can be requested with a query:
NSString *tableID = [accountEntry tableID];
GDataQueryAnalytics *dataQuery;
dataQuery = [GDataQueryAnalytics analyticsDataQueryWithTableID:tableID
startDateString:@"2009-05-18"
endDateString:@"2009-05-22"];
[dataQuery setDimensions:@"ga:country"];
[dataQuery setMetrics:@"ga:pageviews"];
ticket = [service fetchAuthenticatedFeedWithQuery:dataQuery
feedClass:[GDataFeedAnalyticsData class]
delegate:self
didFinishSelector:@selector(dataTicket:finishedWithFeed:)
didFailSelector:@selector(dataTicket:failedWithError:)];