Dylan Hooper
Dylan Hooper

Reputation: 13

Incorrect AVG Session Duration?

I am setting up some google analytics API functions, but my average session duration doesn't seem to be correct. My typical average session duration is 4:10 however I am getting numbers such as 1144 (seconds) or 24.06 minutes. This is WAY off does anyone know what could be happening here? I read something about a incorrect date reference. This is what I am using. Also my users, sessions, and pageviews are also much much less than they should be as well.

$from = date('Y-m-d', time() - 1  24  60  60); // from "yesterday" to "today" --  ' - d  h  m  s ' change (d) day to go back further than (1) day
$to = date('Y-m-d'); // today

$metrics = 'ga:users,ga:pageviews,ga:bounces,ga:sessions,ga:sessionDuration,ga:totalEvents,ga:transactions,ga:transactionRevenue,ga:avgSessionDuration';
$dimensions = 'ga:date,ga:eventCategory,ga:eventAction,ga:eventLabel,ga:deviceCategory';
$sort = "-ga:sessions";
$data = $analytics->data_ga->get('ga:' . $ga_profile_id, $from, $to, $metrics, array('dimensions' => $dimensions, 'sort' => $sort, 'samplingLevel' => 'HIGHER_PRECISION'));

ga:users                          229
ga:pageviews                      2118
ga:bounceRate                     0
ga:sessions                       229
ga:sessionDuration                262079.0
ga:avgSessionDuration             19.074163027656 (calculated to minutes)
ga:transactions                   40     
ga:transactionRevenue             2756.63
ga:totalEvents                    452

Expected Data

Users: ~15000
Pageviews: ~64000
Bounce Rate: ~47.5%
Sessions: ~17500
Average Session Duration: ~4 minutes 10 seconds
Transactions: ~780
Transaction Revenue: ~50000
Total Events: ~350-400

So basically everything is much lower than it should be except for events

Upvotes: 1

Views: 661

Answers (1)

Mike Sullivan
Mike Sullivan

Reputation: 629

Events are an interesting dimension type -- there is no (not set) value, so if a session has an event exists with no value for the Event Category, Event Action or Event Label, the session will be excluded from the report.

Try the same query without the event dimensions, then add them one at a time to see which is causing your data loss.

Upvotes: 1

Related Questions