If GA times out, the result counter is reset

Created on 20 March 2020, about 5 years ago
Updated 10 July 2023, over 1 year ago

Where Google Analytics times out and returns an error, the result counter is reset to 0, and starts retrieving paths from GA at 1. On a site with several hundred thousand paths, we are seeing enough timeouts that GA is never queried the paths with higher numbers, becuase the process keeps starting over.

The problem seems to be in google_analytics_counter_data.inc:

  // The total number of records for this profile.
  $resultcount = @$new_data->results->totalResults;
  // Store it in a variable.
  variable_set('google_analytics_counter_totalpaths', $resultcount);

If there is a timeout, $new_data->results->totalResults is 0, and $resultcount is reset. We probably need a condition:

if (empty($new_data->error)) {
    // The total number of records for this profile.
    $resultcount = @$new_data->results->totalResults;
    // Store it in a variable.
    variable_set('google_analytics_counter_totalpaths', $resultcount);

    ... // down to the end of the function
}

or some more elegant fix.

πŸ› Bug report
Status

Closed: outdated

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom kenorb

    Got similar issues.
    Did some patch for 8.x, potentially fixing the issue. Needs some testing.

  • Status changed to Closed: outdated over 1 year ago
  • πŸ‡ΈπŸ‡°Slovakia kaszarobert

    Because of the Universal Analytics shutdown, version 8.x-3.x is no longer supported.
    If you are still here and experiencing it with the latest version using GA4, then please open an issue about it.

Production build 0.71.5 2024