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 eventsview, view_archive, view_compare, view_favorites. Recorded whenever analytics is enabled.
  • BI eventsfilter_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 on admin_init for 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:

ColumnTypeNotes
idBIGINT UNSIGNED AUTO_INCREMENTPrimary key.
post_idBIGINT UNSIGNED NOT NULLVehicle post ID, or 0 for global events.
event_typeVARCHAR(20)One of the allowed event names.
extra_dataLONGTEXT NULLOptional payload. JSON-encoded for filter_search.
created_atDATETIMEUTC 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

  1. Open the Analytics admin tab.
  2. Enable the master toggle (as24ci_analytics_enabled). Until this is on, no events are recorded.
  3. Decide whether to also enable the BI toggle (as24ci_analytics_bi_enabled) for filter, contact-open and lead-sent events.
  4. (Recommended) Set the data-retention window in days.
  5. (Optional) Enable Require consent mode and connect your consent banner to the as24ci_analytics_consent_check filter — return false for visitors who have not granted consent.
  6. (Optional) Adjust the privacy jurisdiction to surface the correct labels in the admin UI.
  7. To remove all collected data on demand, use the Purge button in the admin UI. The action is gated by the manage_as24_imports capability and a dedicated nonce.

Configuration reference

Option keyPurposeDefault
as24ci_analytics_enabledMaster tracking toggle.'0' (off)
as24ci_analytics_bi_enabledEnables filter / contact / lead events.'1' (on, when analytics is on)
as24ci_analytics_retention_daysDays of history kept by the daily cleanup. Floored to a minimum of 7.180
as24ci_analytics_require_consentWhen '1', events require explicit consent via the filter.'0'
as24ci_analytics_filter_minimizationWhen '1', free-text search keys are stripped from filter_search payloads before storage.'1'
as24ci_analytics_privacy_jurisdictionManual 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_check filter returns true. The default attached value is true, so configuring this mode without wiring a consent integration silently allows tracking.
  • The filter_search payload is minimised: the keys s, search and q are removed by default, and the list is filterable via as24ci_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_cleanup WP-Cron event. The cleanup deletes rows where created_at is 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_enabled is '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_check filter is returning false, or no integration is wired up but a custom plugin is filtering the value to false. Inspect with a temporary add_filter callback that returns true.
  • Old data is not being purged — verify the as24ci_daily_cleanup cron 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_imports capability and the as24ci_purge_analytics nonce. Check the browser network tab for a 403.