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
Comment #3
kaszarobertI fixed the query.