Cleaning (Data Cleaning)
Cleaning (Data Cleaning)
The Cleaning page helps you manage database growth by clearing or trimming WPMC tracking tables. It is designed for admins who want to keep analytics fast, reduce storage usage, and remove test data.
Menu location: WP Admin → WPMC Behavior & Heatmap → Data Cleaning
Admin slug: wpmc-data-cleaning
Source file: /includes/data-cleaning.php
Capability required: manage_options
What tables this page manages
The UI shows three main tables used by the plugin. In this version, “Clicks” refers to the BH Engine table:
Note: {prefix} is your WordPress table prefix
(commonly wp_).
Table size indicator (how it’s calculated)
The size shown in the table is calculated using INFORMATION_SCHEMA:
DATA_LENGTH + INDEX_LENGTH.
If a table does not exist yet, size is shown as 0 MB.
Why size may not drop immediately: MySQL (especially InnoDB) may keep disk space allocated even after deletion. So the size number can stay the same for a while, even if rows are removed. This is normal.
Actions on this page
1) Clear a single table
Each row has a Clear button that removes all data from that table using:
TRUNCATE TABLE.
- Clear Clicks → truncates
{prefix}wpmc_bh_clicks - Clear Views → truncates
{prefix}wpmc_views - Clear Sessions → truncates
{prefix}wpmc_sessions
Each action is protected with a dedicated nonce:
rere_clean_clicks,
rere_clean_views,
rere_clean_sessions.
2) Delete all tracking data
The Delete All Data button truncates all three tables (Clicks, Views, Sessions). This is the fastest way to wipe all WPMC tracking data.
Warning: This cannot be undone. A confirmation prompt appears before the form submits.
Security: nonce rere_clean_all.
3) Delete data older than a date
Use the date picker and click Delete Older Data to delete records older than the selected date. Internally it runs DELETE WHERE column < date queries.
- Clicks:
DELETE ... WHERE ts < 'YYYY-MM-DD 00:00:00' - Views:
DELETE ... WHERE timestamp < ... - Sessions:
DELETE ... WHERE created_at < ...
Security: nonce rere_clean_old.
4) Optimize tables (reclaim disk space)
The Optimize Now action runs:
OPTIMIZE TABLE
for each WPMC table that exists.
Depending on your MySQL engine and hosting, this may take time and may briefly lock tables. It is best used during low-traffic hours.
Security: nonce rere_optimize.
Per-page cleaning (AJAX)
In addition to global cleanup, the plugin provides a per-page cleaning endpoint. This is used when you want to wipe tracking data for a single URL without touching the rest of the database.
Endpoint
wp_ajax_wpmc_clean_page
Parameters
- type:
all,clicks, orviews_sessions - url: the page canonical URL
How URL matching works
The code deletes rows by matching multiple canonical variants, to avoid “trailing slash” and preview mismatches:
• Without trailing slash
• With trailing slash
• With wpmc-preview removed from the query string
Safety
- Admin-only: requires
manage_options - Nonce:
wpmc_page_clean - Defensive URL column detection (INFORMATION_SCHEMA) before deleting
Best practices
- Testing: Clear tables after heavy QA/testing to keep production data clean.
- Performance: Prefer “Delete data older than…” instead of full wipe on busy sites.
- Storage: Use “Optimize” only when needed and preferably during off-peak time.
- Safety: Use per-page cleaning when you only want to remove a single landing page experiment.