• Resolved dormaj

    (@dormaj)


    I pulled up the Overview report (https://spc.pca.org/wp-admin/admin.php?page=wps_overview_page) to share the usage stats and trends (short and long term) with our leadership team on 2-26-2026. I printed it to a PDF and sent it out.

    I went to do the same thing today and there is no data available prior to January 26. Where did it go?

    I’m happy to send you the report PDF from the 26th. But right now I can’t tell leadership what the trend over the past year, much less past Jan 26 is.

    Help, please.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mostafa Soufi

    (@mostafas1990)

    Hi,

    I understand how concerning that is, especially since you had already exported the previous report for your leadership team.

    Based on the cutoff date you mentioned, the first thing I’d recommend checking is whether automatic data cleanup is enabled in WP Statistics.

    Please go to WP Statistics → Settings → Advanced Options → Data Management and check these options:

    – Purge Old Data Daily
    – Purge Data Older Than

    If “Purge Old Data Daily” is enabled, WP Statistics will automatically delete statistics older than the configured number of days. In that case, data that has already been purged can only be restored from a database backup.

    Could you please share the following so we can investigate further?

    1. Your WP Statistics version
    2. A screenshot of the Data Management settings
    3. Whether the site has any database cleanup/optimization plugin or scheduled maintenance enabled

    Once we have that information, we can confirm whether this was caused by retention/cleanup settings or if something else needs to be investigated.

    Best

    Thread Starter dormaj

    (@dormaj)

    Hi Mostafa,

    Thank you.  Yes, Purge was set to ‘180 days’.  No need for further investigation.

    How do I recover that history data?  I have database backups (element of full backups) from 1-18-2026 and 5-18-2026.  Is there some way to merge the Statistics data in these databases with the current database?

    Also, I would suggest you display the Purge Data value prominently in the Overview (maybe, in the blue header area).    The parameter is currently fairly well hidden, and IMO should default to ‘forever’.    As far as I can tell, it doesn’t cost you anything (storage or processing) for ‘180 days’ vs. ‘forever’.    Why pick that arbitrary value?  ‘One year’ makes infinitely more sense.    

    I appreciate your help.  Thank you!

    Jeff

    Plugin Author Mostafa Soufi

    (@mostafas1990)

    Hi Jeff,

    Thanks for confirming, that explains it. With retention at 180 days the nightly job at midnight removes detail rows older than the cutoff. 180 days back from today lands at the end of January, which matches what you are seeing.

    1. Change the setting before you restore anything

    WP Statistics → Settings → Advanced Options, “Purge Old Data Daily” section, set the retention dropdown to “Keep data forever” and save. If you put old rows back while it still says 180 days, tonight’s run deletes them again.

    2. Check what you may still have

    The cleanup does not touch the daily totals table. If you were on 14.16 or newer through that period, your per day visitors and views may still be there:

    SELECT date, visitors, views FROM wp_statistics_summary_totals ORDER BY date;

    (adjust wp_ to your prefix). No per page or per referrer breakdown, but it usually covers the trend line a leadership report needs, without restoring anything.

    3. Merging the old data back

    It works, with care:

    – Load the 18 Jan 2026 backup into a separate database, not your live one.
    – Find your live cutoff first: SELECT MIN(last_counter) FROM wp_statistics_visitor;
    – Copy only rows older than that cutoff, so nothing overlaps. Tables and date columns: wp_statistics_visitor (last_counter), wp_statistics_pages (date), wp_statistics_visitor_relationships (date), wp_statistics_exclusions (date).
    – Example: INSERT IGNORE INTO live.wp_statistics_visitor SELECT * FROM backup.wp_statistics_visitor WHERE last_counter < '2026-01-29'; If the backup came from an older plugin version the columns may differ, in that case list the column names explicitly.
    – Keep the original row IDs. The relationships table points at visitor and page IDs, so renumbering breaks the links. Your surviving live rows were all created after 18 Jan, so their IDs are higher and should not collide.
    – Test on a staging copy and take a fresh backup of live before writing anything.

    On coverage: since the 180 day setting was already active, the January backup should reach back to roughly July 2025 and the May backup to roughly November 2025. So January is the one that matters for the older history, and May can fill the gap between them.

    One correction to make afterwards: each cleanup run adds what it removed into wp_statistics_historical as a running total. If you re-import the detail rows, those get counted twice in all time figures. After the merge, review that table and reduce or clear the rows the cleanup added.

    4. Your feedback

    Fair points and I will pass both on. “Keep data forever” is already an option, but the default is 180 days and the control sits low in Advanced Options, which is exactly how you got caught. In recent versions the job aggregates rather than simply deletes, so all time visitors and views survive while the detailed rows go, and we should say that clearly where people can see it. It is not quite free to keep everything, on busy sites those tables grow into millions of rows and reports slow down, which is why a default exists at all. But the value should be visible up front rather than buried.

    Best

    Thread Starter dormaj

    (@dormaj)

    Mostafa,

    Thanks so much for the timely and excellent instructions on my data restore and merge capability.  And the feedback on my suggestions.

    Please close the support ticket if it is not already closed.

    Cheers,

    Jeff

    Plugin Author Mostafa Soufi

    (@mostafas1990)

    Hi Jeff,

    You’re welcome! I’m glad the instructions were helpful.

    Best

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.