Skip to content

Fetaure: Add Analytics Admin Page, Navigation & Controls#203

Open
alaca wants to merge 13 commits intodevelopfrom
feature/analytics-admin-page
Open

Fetaure: Add Analytics Admin Page, Navigation & Controls#203
alaca wants to merge 13 commits intodevelopfrom
feature/analytics-admin-page

Conversation

@alaca
Copy link
Collaborator

@alaca alaca commented Mar 20, 2026

Description of the Change

Adds a new "Analytics" submenu page under the Mailchimp admin menu
Includes date range selector (presets + custom date pickers), list filter dropdown, and a deep link to Mailchimp's audience analytics dashboard
Renames the existing top-level submenu item to "Form Settings" so both pages are clearly distinguished

Closes #197

How to test the Change

Verify "Form Settings" and "Analytics" appear as submenu items under Mailchimp when an account is connected
Verify the Analytics submenu does not appear when no Mailchimp account is connected
Confirm date range dropdown works with all presets and shows resolved date text
Confirm selecting "Custom" reveals from/to date pickers
Confirm that the list filter populates from connected lists and defaults to the currently selected list
Confirm that changing any filter dispatches a refresh event
Verify the deep link opens the Mailchimp dashboard in a new tab
Verify that Chart.js and analytics assets only load on the Analytics page

Changelog Entry

  • Added new "Analytics" submenu page under Mailchimp with date range selector, list filter, and deep link to Mailchimp audience analytics
  • Renamed the default Mailchimp submenu item to "Form Settings"
  • Analytics page only appears when a Mailchimp account is connected
  • Assets (Chart.js, analytics CSS/JS) are conditionally loaded only on the Analytics page

Credits

Props @alaca

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@alaca alaca requested a review from iamdharmesh March 20, 2026 09:55
@github-actions github-actions bot added this to the 2.1.0 milestone Mar 20, 2026
@github-actions github-actions bot added the needs:code-review This requires code review. label Mar 20, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Analytics” admin submenu under the plugin’s Mailchimp menu, providing UI controls for selecting a date range (presets + custom), filtering by list, and linking out to Mailchimp’s audience analytics dashboard. It also renames the existing settings submenu entry to “Form Settings” to distinguish it from the new Analytics page.

Changes:

  • Register a new Analytics admin submenu page and conditionally enqueue its CSS/JS (including Chart.js).
  • Add an Analytics template with date range + list filters and an external deep link to Mailchimp analytics.
  • Attempt to rename the default settings submenu item to “Form Settings”.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
mailchimp.php Bootstraps the new Analytics class during plugin load.
includes/class-mailchimp-analytics.php Registers the Analytics submenu and enqueues Analytics assets + Chart.js.
includes/class-mailchimp-admin.php Adds a submenu entry intended to rename the default “Mailchimp” settings submenu item.
includes/admin/templates/analytics.php New Analytics admin page markup (filters + deep link).
assets/js/analytics.js Implements filter interactions and dispatches a refresh event on changes.
assets/css/analytics.css Styles the Analytics filters/content/deep link layout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @alaca. This looks good overall. I’ve added a few points for discussion, but otherwise this looks good. There is also some feedback from Copilot, could you please review it and address the valid items? Feel free to ignore anything that isn’t relevant.

Thank you.


$user = get_option( 'mc_user' );
$is_logged_in = ! ( ! $user || ( ! get_option( 'mc_api_key' ) && ! mailchimp_sf_get_access_token() ) );
$lists = get_option( 'mailchimp_sf_lists', array() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use existing function. Something like:

$lists    = ( new Mailchimp_List_Subscribe_Form_Blocks() )->get_lists();

Though we should move get_lists() to utils, but it’s fine not to handle that in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not resolved yet.

@alaca alaca requested a review from iamdharmesh March 24, 2026 11:15
@alaca
Copy link
Collaborator Author

alaca commented Mar 24, 2026

@iamdharmesh this is ready for your review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Simple Analytics] Add Analytics Admin Page, Navigation & Controls

3 participants