[Simple Analytics] Subscriber Change Over Time Chart & Mailchimp API Integration#206
[Simple Analytics] Subscriber Change Over Time Chart & Mailchimp API Integration#206iamdharmesh wants to merge 13 commits intofeature/data-layer-and-form-event-trackingfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “Subscriber change over time” analytics section (bar + doughnut charts) backed by a new admin AJAX endpoint that fetches Mailchimp list activity and aggregates it for charting.
Changes:
- Register a new backend data provider (
Mailchimp_Subscriber_Activity) and hook an admin AJAX action for subscriber activity. - Add new Analytics admin template markup for the subscriber activity card (states, charts, totals).
- Extend the analytics JS/CSS to fetch and render the diverging bar chart + totals doughnut, and update styling via SCSS.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| mailchimp.php | Boots the new subscriber activity provider class. |
| includes/class-mailchimp-subscriber-activity.php | New AJAX endpoint + caching + date-range filtering/aggregation for Mailchimp activity data. |
| includes/admin/templates/analytics.php | Adds subscriber activity section markup; adjusts deep link button styling. |
| assets/js/analytics.js | Adds subscriber activity module (Chart.js rendering) and introduces WP i18n usage. |
| assets/css/analytics.scss | New SCSS-based styling for analytics page and subscriber activity card. |
| assets/css/analytics.css | Removes the previously committed compiled CSS source file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
QA Status: Needs Feedback ❓Hi @iamdharmesh, Thanks for working on this—overall, it works as per the defined scope. I have a few questions and observations related to the chart data and UI:
Next Step: Moving back to In-Progress for feedback. |
|
Thanks for testing this @ankitguptaindia.
Yes, we are using transient caching which expires after every 15 mins. So, you will get updated data in 15 mins.
Done. Thanks.
Done. Thanks |





Description of the Change
The PR adds a Subscriber change over time section on the Analytics admin page, a diverging bar chart (new subscribers vs unsubscribes) and a totals doughnut with net change, driven by the Mailchimp Marketing API
lists/{list_id}/activityendpoint. The section loads on the existingmailchimp-analytics-refreshevent so it stays independent from KPIs and Form Performance section failures in this request do not block other analytics UI.Technical Details:
Backend:
Mailchimp_Subscriber_Activityclass (includes/class-mailchimp-subscriber-activity.php): admin AJAX actionmailchimp_sf_get_subscriber_activity, capability check (MCSF_CAP_THRESHOLD), nonce (mailchimp_sf_analytics_admin_nonce), and validatedlist_id/date_from/date_to(Y-m-d).limited: truewhen the selected span exceeds what Mailchimp can supply so the UI can show an info notice.mailchimp_sf_subscriber_activity_+ hash) so one cache entry serves many date-range requests.init()’d frommailchimp.phpnext to existing analytics classes.Frontend:
includes/admin/templates/analytics.php: new card markup for the section (title, date subtitle, notice, chart + totals, loading/error/empty states). Strings use themailchimptext domain.assets/js/analytics.js: subscribes to filter refresh, POSTs toadmin-ajax.php, renders Chart.js bar (diverging: positive new subs, negative unsubs) and doughnut for range totals; handles empty, error, and limited-range notice.assets/css/analytics.scss(and builtdist/assets vianpm run build): layout (chart + totals column), legend, notice/error/loading states, responsive behavior.Closes #200
How to test the Change
Changelog Entry
Credits
Props @iamdharmesh @builtbytay April Domingo Cameron Campbell
Checklist: