Documentation · Technical Documentation
Analytics Tracking
This document describes how the ADP Car Market Hub plugin records visitor and business-intelligence (BI) events for vehicle listings, where the data is stored, how it is retained and which privacy controls are available.
When to use this document
Read this document if you need to:
- Understand which front-end interactions are tracked and which are not.
- Configure data retention or disable tracking for privacy reasons.
- Hook the consent system into the site's cookie or consent banner.
- Audit how the analytics table is created, written and cleared.
For the underlying REST endpoint that receives events from the front-end pixel, see REST API Endpoints.
Overview
Analytics is implemented in the AS24CI\Analytics class. It
maintains a single custom table and records typed events that
power the Analytics admin tab and the dashboard widget.
Two tracking layers are distinguished:
- Page-view events —
view,view_archive,view_compare,view_favorites. Recorded whenever analytics is enabled. - BI events —
filter_search,contact_open,lead_sent. Recorded only when both analytics and the BI toggle are enabled.
Front-end events are submitted by a small tracking pixel
enqueued in wp_footer that POSTs to
/wp-json/as24ci/v1/analytics/track. PHP-side helpers
(Analytics::track_view(), track_filter_search(),
track_contact_open(), track_lead_sent()) write directly to
the table when called from server-side flows.
Requirements or prerequisites
- WordPress with the REST API available (default).
- Permission to create custom tables (
dbDelta()is used during activation and onadmin_initfor upgrades). - A privacy / consent strategy if your site is subject to GDPR or comparable legislation. See Operational notes below.
Database schema
The plugin stores events in <prefix>as24ci_analytics:
| Column | Type | Notes |
|---|---|---|
id | BIGINT UNSIGNED AUTO_INCREMENT | Primary key. |
post_id | BIGINT UNSIGNED NOT NULL | Vehicle post ID, or 0 for global events. |
event_type | VARCHAR(20) | One of the allowed event names. |
extra_data | LONGTEXT NULL | Optional payload. JSON-encoded for filter_search. |
created_at | DATETIME | UTC timestamp. |
Indexes: (post_id, event_type, created_at),
(event_type, created_at), (created_at).
The schema version is stored in
as24ci_analytics_db_version and dbDelta() is re-applied when
the version on disk changes.
Step by step instructions
- Open the Analytics admin tab.
- Enable the master toggle (
as24ci_analytics_enabled). Until this is on, no events are recorded. - Decide whether to also enable the BI toggle
(
as24ci_analytics_bi_enabled) for filter, contact-open and lead-sent events. - (Recommended) Set the data-retention window in days.
- (Optional) Enable Require consent mode and connect your
consent banner to the
as24ci_analytics_consent_checkfilter — returnfalsefor visitors who have not granted consent. - (Optional) Adjust the privacy jurisdiction to surface the correct labels in the admin UI.
- To remove all collected data on demand, use the Purge button
in the admin UI. The action is gated by the
manage_as24_importscapability and a dedicated nonce.
Configuration reference
| Option key | Purpose | Default |
|---|---|---|
as24ci_analytics_enabled | Master tracking toggle. | '0' (off) |
as24ci_analytics_bi_enabled | Enables filter / contact / lead events. | '1' (on, when analytics is on) |
as24ci_analytics_retention_days | Days of history kept by the daily cleanup. Floored to a minimum of 7. | 180 |
as24ci_analytics_require_consent | When '1', events require explicit consent via the filter. | '0' |
as24ci_analytics_filter_minimization | When '1', free-text search keys are stripped from filter_search payloads before storage. | '1' |
as24ci_analytics_privacy_jurisdiction | Manual jurisdiction override; 'auto' lets the plugin detect. | 'auto' |
For the full list of plugin options, see Options And Settings Storage.
Operational notes
- The master toggle defaults to off so analytics is opt-in.
- When Require consent is enabled, the plugin blocks the event
unless the
as24ci_analytics_consent_checkfilter returnstrue. The default attached value istrue, so configuring this mode without wiring a consent integration silently allows tracking. - The
filter_searchpayload is minimised: the keyss,searchandqare removed by default, and the list is filterable viaas24ci_analytics_filter_blocked_keys. - Page-view events (
view,view_archive, etc.) bypass the BI toggle but still respect the master toggle and consent gate. - Data retention runs daily through the
as24ci_daily_cleanupWP-Cron event. The cleanup deletes rows wherecreated_atis older than the configured window. - Purge calls truncate the table immediately and run regardless of the current toggle state, so collected data can always be removed on demand.
- Recorded data is deliberately small: vehicle ID, event type, optional minimised payload, timestamp. The plugin does not store IP addresses, user agents, session IDs or visitor identifiers in this table.
- The analytics table is dropped on uninstall (regardless of the delete content on uninstall toggle) because it holds visitor-tracking data. See Uninstall And Cleanup Behavior.
Privacy and jurisdiction
The plugin provides a list of recognised jurisdictions
(gdpr, dsgvo, revdsg, uk_gdpr, generic) and tries to
auto-detect a suitable label from site settings. The detection
logic is informational; the legal decisions about lawful basis
and consent remain with the site owner. Verify the detected
jurisdiction in the current plugin version before relying on it
for compliance documentation.
Troubleshooting
- No events recorded — confirm
as24ci_analytics_enabledis'1'. The master toggle defaults to off. - Page views appear but filter searches don't — the BI
toggle (
as24ci_analytics_bi_enabled) is off. - All events silently dropped after enabling consent — the
as24ci_analytics_consent_checkfilter is returningfalse, or no integration is wired up but a custom plugin is filtering the value tofalse. Inspect with a temporaryadd_filtercallback that returnstrue. - Old data is not being purged — verify the
as24ci_daily_cleanupcron event is registered and that WP-Cron (or an external cron) is running. See Cron Events And Scheduler. - Purge button does nothing — the AJAX action requires the
manage_as24_importscapability and theas24ci_purge_analyticsnonce. Check the browser network tab for a403.