Reputation: 72
I have generated a specific report in Google Analytics site.
http://www.google.com/analytics
This report makes reference to the most visited content of the site, you can do this by accessing the following section:
Reporting > Behavior > Site Content > All pages
And setting up the metrics to Pageviews
However I've got problems by generating this report through the API. How can I get the same results by making a call to the Google Analytics-API?
In Java should be something like this:
private static GaData getResults(Analytics analytics, String profileId) throws IOException {
// Query the Core Reporting API for the number of page views
// in the past seven days.
return analytics.data().ga()
.get("ga:" + profileId, "7daysAgo", "today", "ga:pageviews")
.execute();
}
But I don't know how to define the desired behavior stated above, any ideas?
Upvotes: 2
Views: 839
Reputation: 5168
You should review the full list of dimensions and metrics and decide what combination of information you are trying to request. in your case probably the metric ga:pageviews and the dimension ga:pagePath. the Core reporting developer guides gives several examples of making requests for dimensions and metrics.
analytics.data().ga()
.get(tableId, // Table Id.
"2012-01-01", // Start date.
"2012-01-15", // End date.
"ga:pageviews") // Metrics.
.setDimensions("ga:pagePath")
.setMaxResults(25);
Here is the specific Java reference doc to the method you are trying to call.
Upvotes: 2