Reputation: 1215
Our app uses the Google Analytics Rest API. We'd like to get the number of page views generated by different links to the site.
We have a query that works fine for this:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga:(our ID)&metrics=ga:visitors&filters=ga:pagePath=@kc=321&start-date=2014-04-26&end-date=currentDate3&access_token=(access token)
But we also want to track the number of sustained views for different visitors, which we define as visits where the user stays on the page for over 20 seconds. Here's what we have right now but it is not working. It never seems to go above 1, even if there are multiple sustained visits.
https://www.googleapis.com/analytics/v3/data/ga?ids=ga:(our ID)&metrics=ga:visitors&filters=ga:pagePath=@kc=321&segment=dynamic::ga:timeOnPage>20&start-date=2014-04-26&end-date=currentDate&access_token=(access token)
Upvotes: 0
Views: 1281
Reputation: 116868
All visitor
and visit
based dimensions and metrics have been renamed to instead use user
and session
respectively. I am using Google Analytics Query Explorer 2 to test this so will be using the new column names.
Taking in to that account I assume that you mean that you want to track the number of sustained Views
for different users, which you define as sessions where the time they spent on the page is for over 20 seconds. (Are you sure your not mixing things up?)
Which really means you want to know how many people where on the site at the time there was someone who was looking at a page for more then 20 seconds? Also I don't see you requesting Views anywhere.
I think your problem is your segment, try adding it as part of the filter.
https://www.googleapis.com/analytics/v3/data/ga?ids=ga:(our ID)&metrics=ga:users&filters=ga:pagePath=@kc=321;ga:timeOnPage>20&start-date=2014-04-26&end-date=currentDate&access_token=(access token)
That being said you might also want to look at. ga:sessionDurationBucket might be better to know how long there session was uposed to there ga:timeOnPage.
If this doesn't help could you try and explain a little better what you are trying to do and what you are expecting to see. I'm not sure I understand the query you are trying to create.
Upvotes: 1