Skip to content

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

Merged
iamdharmesh merged 15 commits into
feature/simple-analyticsfrom
feature/data-layer-and-form-event-tracking
May 13, 2026
Merged

[Simple Analytics] Add Data Layer & Form Event Tracking#213
iamdharmesh merged 15 commits into
feature/simple-analyticsfrom
feature/data-layer-and-form-event-tracking

Conversation

@iamdharmesh
Copy link
Copy Markdown
Collaborator

ORIGINAL PR: #204
It was merged accidently old feature branch

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.

@iamdharmesh iamdharmesh merged commit 2ee96c0 into feature/simple-analytics May 13, 2026
@iamdharmesh iamdharmesh mentioned this pull request May 13, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants