Survey & Poll System
Overview
The Survey & Poll system provides a flexible form-based solution for collecting attendee feedback, running polls, and gathering data during events. Its backend provides submitted-response metrics, optional live-result events, and attendee-link suppression for anonymous responses. Rendering, public access, and reporting privacy require the corresponding form/page/application configuration.
Form Types
Survey Type
The primary form type for collecting responses. Surveys can operate in two modes:
Standard Survey Mode (poll_mode: false)
- Designed for collecting detailed feedback
- Results are typically not shown to respondents
- Stores presentation settings for progress and pagination; the installed renderer must consume them
- Ideal for post-event feedback, registration surveys, and data collection
Poll Mode (poll_mode: true)
- Enables live result broadcasting via WebSockets
- Results can be displayed to respondents immediately after submission
- Optimized for real-time audience engagement
- Ideal for live Q&A, audience voting, and interactive sessions
Deprecated: Poll Type
The poll form type is deprecated and should not be used for new implementations. Use survey type with poll_mode: true instead.
Setup workflow
- Create or open the project form and select the Survey form type (
form_type: survey). Define fields and stable slugs in its form schema. - Open Survey Settings. The current dashboard shows Poll Mode, Response Settings, Display Settings, Completion Settings, and Analytics Settings cards for survey forms.
- Configure the survey deliberately, then bind it to the intended portal page. Confirm the page/group rules and form reference for the callers you intend to support.
- Test field validation, response persistence, reporting access, and optional live results with authorized test data before publishing the experience.
The settings are stored in custom_settings, not a separate survey table. A SurveySettings wrapper is available only when the form's form_type is survey. Deprecated poll forms are not equivalent to this wrapper.
Current dashboard/backend differences
| Setting | Dashboard source | Backend helper/rules |
|---|---|---|
results_display | Percentage, count, bar, or pie presentation options | Private, public, or after_submit visibility values |
live_results_cache_ttl | Input range 0–3600 | Declared settings-rule range 1–60; getter fallback 5 |
questions_per_page | 0 means all in the UI helper text | Declared settings-rule minimum 1 when supplied |
redirect_delay | Input maximum 60 | Declared settings-rule maximum 30 |
show_live_results | Shown conditionally under poll mode | Poll mode forces the runtime predicate true |
These are implementation differences, not a promise that every rule is invoked by every save path. Inspect the stored values and test the renderer/API behavior. In particular, a chart format selected in the dashboard does not establish restricted reporting visibility.
Configuration Options
The tables list configuration keys and illustrative values. Only defaults explicitly identified as runtime/helper fallbacks below are established by the inspected backend source; set presentation/completion options explicitly and verify the renderer rather than relying on omitted-value defaults.
Poll Mode Settings
| Option | Type | Default or illustrative value | Description |
|---|---|---|---|
poll_mode | boolean | false | Enables poll functionality with live result broadcasting |
show_live_results | boolean | false when absent in the runtime predicate | Enables live results for a standard survey; poll mode forces live results even when this flag is false |
results_display | string | 'private' | Visibility policy: 'private', 'public', or 'after_submit'; presentation of values is a separate concern |
live_results_cache_ttl | integer | 5 | Cache duration in seconds for live results |
Response Settings
| Option | Type | Default or illustrative value | Description |
|---|---|---|---|
anonymous_responses | boolean | false | The request clears attendee_id; network/device attribution can still be recorded |
single_response_only | boolean | true | Survey helper rule for attendee submissions; reconcile with form security_settings and the API path |
allow_response_edit | boolean | false | Allow respondents to modify their submission |
require_authentication | boolean | false when absent in the helper | Helper-level authentication check; page access and API authorization are separate |
Response identity and submission limits
anonymous_responses clears attendee_id during request preparation. It does not mean the stored record contains no identifying data: the request records IP address, user agent, visitor/session identifiers, and server-derived attribution. Keep raw responses in authorized reporting and verify the deployed public read policy before collecting sensitive feedback.
The survey helper's canRespond() checks attendee-linked submitted responses when single-response mode is enabled. The generic form response request separately uses security_settings.allow_multiple_submissions for attendee uniqueness and requires a UUID unique within the form. These are different mechanisms; a survey setting alone does not prove one response per anonymous person. Guest access, session identity, retry idempotency, and edit/delete authorization need their own checks.
The response API writes field values by configured field slug. Arrays are serialized as JSON for storage; the metrics breakdown groups stored values, so a multiselect distribution is not necessarily an individual-option tally. Submitted status controls metrics inclusion. Required fields and option values are validated against the form definition.
For response submission, start with Forms Builder: choose the API workflow: standard/survey responses use the form-slug /forms/{form}/responses path and the endpoint’s fields map, distinct from registration and native quiz attempts. Use the deployed REST reference for the create operation’s current required fields, UUID/status and permission contract; a metrics read token does not itself prove response-write access. Follow the same guide’s readback, privacy and recovery precautions before returning any raw response to a browser.
For page context, follow Obtain the method ID and page key. Confirm the serving portal, active installed page, form binding and audience with the project administrator. Inside an installed plugin, prefer the GxP Store, which receives the host’s page context; do not replace it with a privileged project key. For external clients, use only the intended page’s public key and the principal/header arrangement described in that authentication guide.
For the documentation feedback integration, the dedicated Documentation Feedback guide describes the hidden rollout, private-reporting requirements, and prepared receipt API. That receipt release is separate from the response path documented here.
Display Settings
| Option | Type | Default or illustrative value | Description |
|---|---|---|---|
show_progress_bar | boolean | true | Display progress indicator for multi-page surveys |
show_question_numbers | boolean | true | Show numbering on questions |
randomize_questions | boolean | false | Randomize question order per respondent |
randomize_options | boolean | false | Randomize answer options within questions |
questions_per_page | integer | null | Questions per page (null = all on one page) |
Completion Settings
| Option | Type | Default or illustrative value | Description |
|---|---|---|---|
show_completion_message | boolean | true | Display a message after submission |
completion_message | string | 'Thank you for your response!' | Custom completion message |
redirect_url | string | null | URL to redirect after completion |
redirect_delay | integer | 3 | Seconds before redirect (if redirect_url is set) |
Analytics Settings
| Option | Type | Default or illustrative value | Description |
|---|---|---|---|
track_time_per_question | boolean | false | Stored timing intent; instrumentation must supply timing metadata |
track_abandonment | boolean | false | Stored tracking intent; incomplete response records must actually be created |
Presentation, randomization, completion, and tracking keys do not implement those behaviors by themselves. The inspected backend stores settings and computes metrics from saved records; verify the installed form renderer and instrumentation for the keys it consumes. An abandonment setting alone cannot measure visitors who never create a response.
API Endpoints
These survey routes remove auth:sanctum and require enforce.form.page.context. Supply valid portal-page context bound to the requested form and satisfying its page/group access rules. The controller resolves the form within the request’s project by slug and rejects non-survey forms. Public callers need the required page context. The shared gate has a separate authenticated dashboard-admin bypass; do not expose dashboard credentials to a browser integration. Live deployed acceptance must be checked separately.
Get Form Metrics
GET /api/v1/projects/{team}/{project}/survey/{form}/metrics
Returns aggregate metrics for the form including total responses, completion rate, and average completion time.
Response:
{
"data": {
"total_responses": 150,
"completion_rate": 85.0,
"average_completion_time": 180,
"unique_respondents": 120,
"abandonment_rate": 15.0,
"responses_today": 20,
"responses_this_week": 80
}
}
Summary completion and abandonment rates are percentages on a 0–100 scale. Total responses counts submitted records; unique respondents counts distinct non-null attendee IDs and can differ from anonymous/browser visitor counts. Average completion time is nullable and requires metadata.completion_time_seconds on submitted responses.
Get Question Metrics
GET /api/v1/projects/{team}/{project}/survey/{form}/metrics/question/{slug}
Returns detailed metrics for a specific question identified by its slug.
Response:
{
"data": {
"field_id": 45,
"field_slug": "favorite_color",
"field_label": "What is your favorite color?",
"field_type": "option-select",
"total_responses": 145,
"distribution": {
"blue": {"count": 60, "percentage": 41.38},
"red": {"count": 45, "percentage": 31.03},
"green": {"count": 40, "percentage": 27.59}
}
}
}
Get All Questions Metrics
GET /api/v1/projects/{team}/{project}/survey/{form}/metrics/questions
Returns breakdowns only for supported distribution field types (including option-select subtypes), not every free-text question. Each breakdown uses field metadata and a value-keyed distribution object. Its denominator is the number of saved answer-value rows for that field, not necessarily every form submission or unique person.
Get Time Series Data
GET /api/v1/projects/{team}/{project}/survey/{form}/metrics/time-series
Returns response data over time for charting and trend analysis.
Query Parameters:
start_date- Start of date range (ISO 8601)end_date- End of date range (ISO 8601)interval- Grouping interval:hour,day,week,month
The source filters submitted responses by created_at, applies inclusive start/end comparisons, groups existing rows into formatted period/count pairs, and sorts by period. It does not fill missing periods with zero rows. Validate the deployed database timezone when interpreting hour/day boundaries. Invalid intervals or an end date before the start date fail request validation.
Get Live Results
GET /api/v1/projects/{team}/{project}/survey/{form}/live-results
Returns current poll results. Primarily used for initial state before WebSocket connection.
Response:
{
"data": {
"questions": [
{
"field_slug": "session_rating",
"field_label": "Session rating",
"distribution": {
"excellent": {"count": 45, "percentage": 50.0},
"good": {"count": 30, "percentage": 33.33},
"fair": {"count": 15, "percentage": 16.67}
}
}
],
"total_responses": 90,
"calculated_at": "2024-01-15T10:30:00Z"
}
}
WebSocket Channels
Live Results Channel
survey.{project_id}.{form_id}.results
Subscribe to this channel to receive real-time updates when new responses are submitted.
Event: survey.response.submitted (listen as .survey.response.submitted in Echo)
Payload:
{
"form_id": 123,
"questions": [],
"total_responses": 91,
"updated_at": "2024-01-15T10:30:05Z",
"calculated_at": "2024-01-15T10:30:05Z"
}
The source broadcasts on a public Channel, after commit, only for survey forms whose live-results predicate is enabled. Queue/broadcast infrastructure must process the event; a successful submission does not prove browser delivery. The queued listener invalidates the metrics cache. The event payload independently calls the cached metrics service, while invalidation runs in a separate queued listener. If the broadcast reads first, it can carry an older aggregate with a new updated_at. Inspect calculated_at for aggregate freshness; receipt time and event time do not establish that the new response is included. Reconcile through an authorized live-results read after invalidation/cache expiry, and handle API/transport failures separately. Do not resubmit the response merely to refresh a count. No queue-order guarantee is established by this source review.
results_display is a visibility-policy value, not a percentage/count formatting option. Poll mode returns public from the settings helper. The live-results controller and event shown here gate on shouldShowLiveResults() rather than proving that every visibility policy is enforced. Do not treat private alone as proof that a live-results payload is restricted; verify the deployed page-context and reporting behavior for your use case.
Usage Examples
These PHP snippets illustrate trusted server-side model configuration, not a complete client integration. Define the actual form fields/schema, project access, and portal-page binding separately; the snippets do not create a ready-to-use questionnaire or prove a published renderer.
Creating a Poll (PHP)
use App\Models\ProjectForm;
$poll = ProjectForm::create([
'project_id' => $project->id,
'name' => 'Session Feedback Poll',
'form_type' => 'survey',
'custom_settings' => [
'poll_mode' => true,
'show_live_results' => true,
'results_display' => 'public',
'live_results_cache_ttl' => 5,
'single_response_only' => true,
'require_authentication' => true,
],
]);
Creating an Anonymous Survey (PHP)
use App\Models\ProjectForm;
$survey = ProjectForm::create([
'project_id' => $project->id,
'name' => 'Post-Event Feedback',
'form_type' => 'survey',
'custom_settings' => [
'poll_mode' => false,
'anonymous_responses' => true,
'single_response_only' => true,
'require_authentication' => false,
'show_progress_bar' => true,
'show_question_numbers' => true,
'show_completion_message' => true,
'completion_message' => 'Thank you for your feedback!',
'track_time_per_question' => true,
'track_abandonment' => true,
],
]);
Fetching Metrics (JavaScript)
These helpers assume an Axios instance already configured with the required portal-page context and serving API origin. Pass a form slug for HTTP lookup; use numeric project/form IDs only for the broadcast channel. Do not use privileged dashboard credentials in a public client.
import axios from 'axios';
async function fetchSurveyMetrics(team, project, formSlug) {
const response = await axios.get(
`/api/v1/projects/${team}/${project}/survey/${formSlug}/metrics`
);
return response.data;
}
async function fetchQuestionMetrics(team, project, formSlug, questionSlug) {
const response = await axios.get(
`/api/v1/projects/${team}/${project}/survey/${formSlug}/metrics/question/${questionSlug}`
);
return response.data;
}
Listening for Live Updates (JavaScript with Echo)
function subscribeToPollResults(projectId, formId, onUpdate) {
if (!window.Echo) throw new Error('Configure the host Echo connection before subscribing.');
const channel = window.Echo.channel(`survey.${projectId}.${formId}.results`);
const eventName = '.survey.response.submitted';
let active = true;
const callback = (event) => {
if (active) onUpdate(event);
};
channel.listen(eventName, callback);
return () => {
if (!active) return;
active = false;
channel.stopListening(eventName, callback);
};
}
Retain the returned cleanup function and call it when the consumer unmounts or changes forms. It removes only its owned callback; another consumer can keep using the shared channel. The helper passes aggregates to your callback without logging payloads or applying freshness policy. Use the complete component below for mounting and calculation-time comparison.
Complete Poll Component Example (Vue)
Configure Axios with the serving API origin when embedding this in a different origin; the example uses a relative API path. Use the public portal-page token for the page bound to this form. Configure Echo in the host before mounting if live updates are required. The example reads aggregates only; it does not submit a survey or expose raw response records. It owns its listener, so cleanup removes that callback rather than leaving a channel another component may share.
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import axios from 'axios';
const props = defineProps({
team: String,
project: String,
formSlug: String,
formId: Number,
projectId: Number,
pageToken: String,
});
const results = ref(null);
const loading = ref(true);
const error = ref('');
const controller = new AbortController();
let channel;
let mounted = true;
const eventName = '.survey.response.submitted';
function applyUpdate(event) {
if (!mounted) return;
if (!results.value) {
results.value = event;
return;
}
const incomingTime = Date.parse(event?.calculated_at);
const currentTime = Date.parse(results.value.calculated_at);
// Unknown freshness must not replace an existing result.
if (Number.isFinite(incomingTime)
&& (!Number.isFinite(currentTime) || incomingTime >= currentTime)) {
results.value = event;
}
}
onMounted(async () => {
try {
if (window.Echo) {
channel = window.Echo.channel(`survey.${props.projectId}.${props.formId}.results`);
channel.listen(eventName, applyUpdate);
}
const response = await axios.get(
`/api/v1/projects/${encodeURIComponent(props.team)}/${encodeURIComponent(props.project)}/survey/${encodeURIComponent(props.formSlug)}/live-results`,
{ signal: controller.signal, headers: { 'X-Portal-Page-Token': props.pageToken } },
);
applyUpdate(response.data.data);
} catch {
if (mounted) error.value = 'Could not load survey results. Check page access and live-result settings.';
} finally {
if (mounted) loading.value = false;
}
});
onUnmounted(() => {
mounted = false;
controller.abort();
channel?.stopListening(eventName, applyUpdate);
});
</script>
<template>
<p v-if="loading" role="status">Loading results...</p>
<p v-else-if="error" role="alert">{{ error }}</p>
<section v-else-if="results" aria-label="Survey results">
<div v-for="question in results.questions" :key="question.field_slug">
<h3>{{ question.field_label }}</h3>
<div v-for="(option, value) in question.distribution" :key="value">
<span>{{ value }}: {{ option.percentage }}%</span>
<div class="bar" :style="{ width: option.percentage + '%' }" />
</div>
</div>
<p>Total responses: {{ results.total_responses }}</p>
</section>
</template>
This example performs one initial read and compares incoming events; it does not schedule a reconciliation read after a stale/missing timestamp or after cache invalidation. The consuming application must implement that read using the same authorized live-results endpoint, preserve the displayed result while it is pending, handle failures and cancel work on unmount. Delay/retry according to the deployment’s cache behavior rather than immediately resubmitting the survey or assuming the first repeated read is fresh. Verify that the eventual calculation includes the expected submission; a timestamp comparison alone does not establish that.
The initial read and live events use the same calculated_at comparison: an older aggregate cannot replace a newer one merely because its event arrived later. A result without a valid calculation time can initialize an empty view but cannot replace existing results; reconcile missing freshness through an authorized read. Timestamps are a best-effort freshness signal, not a server revision or queue-order guarantee. Failure text is deliberately generic; inspect request status and page-context configuration in development. Realtime transport failure and API failure are separate conditions, and deployed queue/broadcast acceptance remains necessary.
Troubleshooting and acceptance
| Symptom | Check |
|---|---|
| Survey Settings tab is absent | The form's form_type must be survey; the deprecated poll type does not receive the survey wrapper |
| API returns 404 | Project/form slug, bound portal-page token, page form reference, and group access; restricted context can deliberately look nonexistent |
| Live-results API returns 403 | Runtime live-results predicate; standard surveys need it enabled, while poll mode forces it on |
| Response succeeds but no live event arrives | Exact explicit event name, numeric channel IDs, Echo connection, broadcast driver, and queue processing after commit |
| UI presentation conflicts with policy | Dashboard chart-format values and backend visibility values share results_display; inspect stored configuration and verify actual access |
| Unique respondents is lower than response count | Distinct non-null attendee IDs are counted; anonymous records and repeated submissions have different semantics |
| Completion-time average is null | Submitted responses need numeric completion_time_seconds metadata; the setting alone does not generate timing data |
| No text-question breakdown appears | Aggregate breakdowns include supported distribution field types, not every schema field |
| Results look stale | Cache TTL, invalidation listener execution, and actual calculated_at; queue/cache behavior needs deployed acceptance |
Before release, verify schema/required/option validation, submitted versus draft inclusion, anonymous identity handling, duplicate/retry behavior, authorized reporting, and denied public raw reads. Confirm live broadcasts and cache invalidation separately from HTTP submission. The example's local fixture tests do not establish those platform/database outcomes.