Problem/Motivation

src/GoogleAnalyticsCounterAppManager.php does this merge query for writing the results from GA4 to each URLs:

        $this->connection->merge('google_analytics_counter')
          ->key('pagepath_hash', md5($page_path))
          ->fields([
            'pagepath' => $page_path,
            'pageviews' => $value,
          ])
          ->expression('pageviews', 'pageviews + :pageviews', [':pageviews' => $value])
          ->execute();

That means if for /node/1 the viewcount was saved as 325, then GA4 reports new 410 view count, then 325+410=735 will be saved instead of 410.

Steps to reproduce

You need to set "Update pageviews for content created in the last X days" or "Update pageviews for the last X content".
Run cron multiple times.

Proposed resolution

Remove that expression from the merge query.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

kaszarobert created an issue. See original summary.

  • kaszarobert authored 5fe6a290 on 4.0.x
    Issue #3367984 by kaszarobert: Pageviews are incremented with the new...
kaszarobert’s picture

Status: Active » Fixed

I fixed the query.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.