Skip to content

[Simple Analytics] Add Data Layer & Form Event Tracking#204

Open
alaca wants to merge 13 commits intodevelopfrom
feature/data-layer-and-form-event-tracking
Open

[Simple Analytics] Add Data Layer & Form Event Tracking#204
alaca wants to merge 13 commits intodevelopfrom
feature/data-layer-and-form-event-tracking

Conversation

@alaca
Copy link
Collaborator

@alaca alaca commented Mar 24, 2026

Description of the Change

  • Created a custom database table ({prefix}_mailchimp_sf_form_analytics) for daily aggregated form analytics, with columns for list_id, form_id, event_date, views, and submissions (unique key on list_id, form_id, event_date)
  • Implement client-side form view tracking that adds data-list-id attribute to all form types (block, widget, shortcode) and
    fires an AJAX POST on page load, deduplicated per list_id
  • Hook into successful form submissions via a new mailchimp_sf_form_submission_success action to increment daily submission
  • Table creation runs on plugin activation and via the upgrade routine for existing installs

Closes #198

How to test the Change

  • Activate the plugin on a fresh install and verify the wp_mailchimp_sf_form_analytics table is created
  • Visit a page with a Mailchimp signup form and verify a view is recorded in the analytics table for the correct list_id and
    today's date
  • Place multiple forms (different lists) on one page and verify each list gets its own view count
  • Submit a form successfully and verify the submission count increments
  • Submit a form with invalid data (e.g., missing email) and verify no submission is tracked
  • Navigate to Mailchimp > Analytics in wp-admin and verify that test data is displayed

Changelog Entry

Created a custom database table (mailchimp_sf_form_analytics) for daily aggregated form analytics
Implemented client-side form view tracking via AJAX

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.

@github-actions github-actions bot added this to the 2.1.0 milestone Mar 24, 2026
@github-actions github-actions bot added the needs:code-review This requires code review. label Mar 24, 2026
@alaca alaca requested a review from iamdharmesh March 24, 2026 15:51
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 Data Layer & Form Event Tracking

1 participant