読者です 読者をやめる 読者になる 読者になる

Fight the Future

何かを始めたら、半分成功したのと同じ

Google AnalyticsのデータをJavaで取得する

		// Service Object to work with the Google Analytics Data Export API.
		AnalyticsService analyticsService = new AnalyticsService("gaExportAPI_acctSample_v2.0");
		// ClientLogin Authorization.
		analyticsService.setUserCredentials(userName, password);

		// Create a query using the DataQuery Object.
		DataQuery query = new DataQuery(new URL("https://www.google.com/analytics/feeds/data"));
		query.setStartDate("2010-01-01");
		query.setEndDate("2010-12-31");
		query.setDimensions("ga:pagePath");
		query.setMetrics("ga:pageviews");
		query.setSort("-ga:pageviews");
		query.setIds("ga:xxxxxxx");

		query.setFilters("ga:pagePath==xxx");

		// Make a request to the API, using DataFeed class as the second parameter.
		DataFeed dataFeed = analyticsService.getFeed(query.getUrl(), DataFeed.class);

		for (DataEntry entry : dataFeed.getEntries()) {
			entry.longValueOf("ga:pageviews");
		}

http://code.google.com/intl/ja/apis/analytics/docs/gdata/2.0/gdataJava.html

http://code.google.com/intl/ja/apis/analytics/docs/gdata/gdataReferenceDataFeed.html

http://code.google.com/intl/ja/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html