- Issue created by @jurriaanroelofs
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'keyEvents:viewed_pricing_page' for key 'PRIMARY': INSERT INTO "google_analytics_reports_fields" ("type", "ui_name", "description", "gaid", "data_type", "column_group", "calculation") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => METRIC [:db_insert_placeholder_1] => Key event count for viewed_pricing_page [:db_insert_placeholder_2] => The count of a specific key event. [:db_insert_placeholder_3] => keyEvents:viewed_pricing_page [:db_insert_placeholder_4] => string [:db_insert_placeholder_5] => Event [:db_insert_placeholder_6] => ) in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 45 of /var/www/dxpr.com/web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php).
The module assumes "gaid" is a unique ID in the endpoint where it gets its fields from. It seems like, either the gaid is not unique in the source, or the Field import is wonky.
1. Not sure, have a custom key event / conversion event in your GA4 setup? The event in the error is not in fact duplicated anywhere in the GA4 UI.
2. Go to /admin/config/services/google-analytics-reports-api
3. Press "Import fields" button
When I empty the google_analytics_reports_fields table and try again, same error.
I found a patch in an unrelated issue that fixed the problem for me, and for the person whom the patch originates from:
https://www.drupal.org/project/google_analytics_reports/issues/3323218#c... 🐛 Composer Build issue with Google Vendor Libraries Closed: won't fix
https://www.drupal.org/project/google_analytics_reports/issues/3323218#c... 🐛 Composer Build issue with Google Vendor Libraries Closed: won't fix
I'm sharing the patch again here but full credit should go to @scampbell1
4.0
API module