Surveys, A/B Tests & Integrations
Beyond lead capture, Forms includes built-in survey analytics, multi-variant A/B testing, and seven optional sibling module integrations isolated cleanly under src/Integration/<Module>/.
Surveys & Polls (SurveyAggregator)
Section titled “Surveys & Polls (SurveyAggregator)”SurveyAggregator computes choice distributions, percentages, numeric averages, and Net Promoter Scores (NPS) across non-spam submissions (up to $maxSample = 5000 by default):
<?php namespace ProcessWire;
$forms = Forms::requireInstance($wire);
// Structured analytics array$metrics = $forms->surveyResults('charter-inquiry');
// Accessible frontend SVG charts (requires allow_public_survey_results or $force = true)echo $forms->renderSurveyResults('charter-inquiry');Multi-Variant A/B Testing (AbTestManager)
Section titled “Multi-Variant A/B Testing (AbTestManager)”Define experiments in Setup -> Forms -> A/B Testing (forms-ab-tests) comparing two or more form variants with custom traffic weights:
<?php namespace ProcessWire;
$forms = Forms::requireInstance($wire);
// Selects a sticky weighted variant, records 'served', and renders the formecho $forms->renderAbTest('charter-inquiry-layout', ['theme' => 'modern']);
// Record custom funnel events programmatically ('served' | 'interacted' | 'failed' | 'completed')$forms->recordAbTestEvent('charter-inquiry-layout', 'charter-inquiry-short', 'completed');Browser interaction beacons route through /_forms/ab-event (AbTestManager::recordPublicEvent()) with per-IP rate limiting, per-session 'interacted' deduplication, and atomic counters in forms_ab_counters.
Seven Optional Sibling Integrations
Section titled “Seven Optional Sibling Integrations”| Module | Integration Capabilities |
|---|---|
Ai |
Prompt-to-form generation in the Visual Builder (___generateFormSpecFromPrompt), ai field enrichment, classifySubmission() spam evaluation, and FormsCapabilityProvider (scopes forms:read, forms:write, forms:delete; resources pw://forms/catalog, pw://forms/{slug}; tools forms_list, forms_get, forms_save, forms_submissions_query, forms_submissions_organize, forms_submissions_delete). |
Currency |
Constructs exact minor-unit Money values (resolveMoneyObject) and populates ISO currency dropdowns. |
Payments |
Processes payment fields via hosted /pay/{token} links and recurring subscriptions (processPaymentIntent) and triggers deliverAfterPayment() on afterPaymentLinkPaid, afterPurchase, afterSubscribe, and afterFailure. |
Contacts |
Upserts contacts on afterSubmit, records immutable ConsentPurpose::MarketingEmail consents via Contacts::recordConsent(), exports submission data under modules.forms (collectSubjectData), anonymizes on afterAnonymize, and re-links submissions on afterMerge. |
Campaign |
Subscribes consenting visitors directly to mailing lists via Campaign::subscribe(). |
Headless |
Exposes /api/v1/forms/* (GET /forms, GET /forms/{slug}, GET /forms/{slug}/token, POST /forms/{slug}/validate-step, POST /forms/{slug}/submit, GET /forms/{slug}/survey-results, DELETE /forms/{slug}/submissions/{token}, GET /forms/ab-tests/{handle}, POST /forms/ab-tests/{handle}/events). |
Media |
Stores uploaded attachments in Media Private Vault (owner: 'forms'), streams authenticated downloads, provides temp files for email/webhook attachments, cascades deletion on submission/GDPR erasure, and resolves image_block Media Library assets (falling back cleanly to EntryFilesManager when uninstalled). |