This is an old revision of the document!
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
):cm<index>
, where <index> must be substituted with the Custom Metric index discussed above. For example: cm1
.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.
{{duration}} / {{Total Events}}
(assuming your Custom Metric is called 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 used Totale Events and duration inputs used).