fabian_p
fabian_p

Reputation: 107

Google Analytics API - Data for Line Chart

I want to create a Line Chart using data received by Google Analytics API. It's no problem to plot a chart using Highcharts.js, but I'm searching for a solution for a performant query. The only idea i had is to make 30 Data requests for a 30 Day chart to get the pageviews on each day using the following query:

https://www.google.com/analytics/feeds/data?ids=$id&dimensions=$dimension&metrics=$metric&sort=$sort&start-date=$start&end-date=$end&max-results=$max_results&start-index=$start_index

Isn't there a way to receive this data in only one query?

Upvotes: 1

Views: 1001

Answers (3)

Peter
Peter

Reputation: 1

Try adding the dimension ga:day to the query. This will sort your data per day

Upvotes: 0

OV Web Solutions
OV Web Solutions

Reputation: 825

Well, you can could set your $start and $end date variables to include 30 days. This should reduce your request from 30 to 1.

Upvotes: 0

Ewan Heming
Ewan Heming

Reputation: 4648

I can't actually see the dimensions you're trying to query because you're using variables but you should just be able to use the ga:date dimension to get data split by day.

You can only download a maximum of 10,000 rows per query but you can use the start-index parameter to get the rest.

Upvotes: 2

Related Questions