AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

1.9K members online now
1.9K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
Guide Me

average session duration calculation modification

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

In the average session duration calculation is it possible to exclude sessions that are either less than 5 seconds (mostly bounced session) or more than 15 minutes (mostly where user forgot to kill the window).


Do i need to create a custom metric?

But custom metric doesn't allow me to specify the formula for calculating such a value. 

Thanks in advance.

1 Expert replyverified_user

average session duration calculation modification

Top Contributor
# 2
Top Contributor



by default Google Analytics tracks time based on page loads and their time stamps.

So you need some custom code sending data to GA about users time on the page.

For example

Timer for every 5 seconds, fire 6-12 times

Timer for 1 minute (or 5 minutes), fire 30 (6) times


Each timer cycle should send event to Google Analytics.

You could increment event value and then segment

- users with no timer events (bouncers)

- users with minute timer event value more than 15 (idlers)


I'm not 100% sure if this is the best or most efficient approach but should do the trick.


Just remember that do not create timer that records a hit for every second since there is a limit how many hits one session can have, rest are discarded.

To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.