This guide shown how to log the *duration* of an event and let Google Analytics to report aggregated statistics for it (like the *average duration*).
Record Structured Event
):GA will now be able to receive and sum all the durations you sent. If you don't see it, double check to pass the Custom Metric key as described above.
We'll now instructs GA to calculate an aggregated statistics, the Average Duration.
This will allow GA to calculate the average duration for a group of events. The sum of duration
and Total Events
will be computed on the specific grouping of data displayed by Google Analytics.
You can now use both the Custom Metric and the Aggregated Statistic in your reports.
The example below is for a Custom Report where data are filter for a specific Event Action name, with resulting events grouped by the Event Label string, with outputs showing the calculate custom Average Duration (in addition to the associated Total Events and duration inputs used by GA to compute the formula).
This is an example of the corresponding output:
GA collects all the events satisfying the filter, group them accordingly to our configuration and for each resulting group it sums matching logged duration values and then compute the Average Duration.