Reputation: 113
Some software monitors my website every 2 min 24x7. Their IP is dynamic and comes from all over the world, but session duration is always less than 5 second.
How to add
filters="ga:timeOnPage > 5"
or
filters="ga:sessionDuration > 5"
to
<ga-chart
title="Sessions (by country)"
type="GEO"
metrics="ga:sessions"
dimensions="ga:country"
filters="ga:country==Australia"> //this one works just fine
</ga-chart>
Upvotes: 2
Views: 7626
Reputation: 30431
First of all, I would not recommend using a session duration filter to exclude this traffic. There are a couple reasons why this is a bad idea:
Note: check out this article for more details on how time is calculated in Google Analytics
Anyway, I would recommend finding another way to filter out that traffic. Does this service allow you to add query params to the URL or set a custom HTTP header or anything like that?
To actually answer your question though, if you really wanted to filter by session duration you'd have to use the dimension ga:sessionDurationBucket.
Here's what a sample query might look like that excludes sessions whose duration is less than 5 seconds:
{
"ids": "ga:XXXX",
"metrics": "ga:sessions",
"dimensions": "ga:sessionDurationBucket",
"filters": "ga:sessionDurationBucket!~^[0-4]$"
}
Note: I'm using a regular expression filter here to only include values that aren't 0
, 1
, 2
, 3
, or 4
.
Upvotes: 8