SDK Configuration
Installation
Add the SDK script to your page:
<script src="https://embed.pollpe.com/sdk.js"></script>
PollPe.open(formId, options)
Opens a survey in the specified display mode.
PollPe.open('YOUR_SURVEY_ID', {
mode: 'popup',
params: {},
autoOpen: true,
onComplete: function(data) {}
});
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
formId | string | required | Your survey ID from the PollPe dashboard |
options.mode | string | 'popup' | Display mode: 'popup', 'panel', 'fullscreen', or 'inline' |
options.params | object | {} | Key-value pairs passed as hidden field values |
options.autoOpen | boolean | false | Open the survey immediately when called |
options.onComplete | function | null | Callback fired when the survey is submitted |
options.container | string or Element | null | CSS selector or DOM element for inline mode |
options.height | string or number | '500px' | Iframe height for inline mode (e.g., '600px' or 600) |
Return Value
Returns an object with a close() method:
var survey = PollPe.open('FORM_ID', { mode: 'popup' });
// Close programmatically
survey.close();
Hidden Parameters
Pass context data to your survey using the params option. Each key must match a hidden field name configured in your survey settings.
PollPe.open('FORM_ID', {
mode: 'popup',
params: {
email: '[email protected]',
userId: 'usr_12345',
plan: 'premium'
}
});
The values are passed as URL query parameters to the survey. They are automatically captured in the survey response and visible in your results dashboard.
Hidden field names in params must exactly match the names you configured in your survey's Settings > Hidden Fields. Unmatched keys are ignored.
Completion Callback
The onComplete callback fires when the respondent submits the survey. The survey popup closes automatically after completion.
PollPe.open('FORM_ID', {
mode: 'popup',
onComplete: function(data) {
console.log('Completed survey:', data.formId);
// Show a thank you message, redirect, etc.
}
});
The onComplete callback requires the latest version of the PollPe survey app. If the callback doesn't fire, check with your PollPe account manager.
Display Modes
Popup
Centered modal with a dark backdrop. Closes on click outside, Escape key, or the close button.
PollPe.open('FORM_ID', { mode: 'popup' });
Panel
Slides in from the right side of the screen. 420px wide on desktop, full width on mobile.
PollPe.open('FORM_ID', { mode: 'panel' });
Fullscreen
Takes over the entire viewport. Best for focused, distraction-free survey experiences.
PollPe.open('FORM_ID', { mode: 'fullscreen' });
Inline
Renders the survey inside a container element on your page. The survey becomes part of the page flow -- no overlay, no close button, no backdrop. Use this when you want the survey embedded directly in your content.
<div id="survey-container"></div>
<script src="https://embed.pollpe.com/sdk.js"></script>
<script>
var survey = PollPe.open('FORM_ID', {
mode: 'inline',
container: '#survey-container',
height: '600px',
params: { email: '[email protected]' },
onComplete: function(data) {
console.log('Survey completed');
}
});
// Remove the survey later if needed
survey.close();
</script>
The container option accepts a CSS selector string (e.g., '#my-div', '.survey-wrapper') or a DOM element reference. If the container is not found, a warning is logged to the console.
Unlike overlay modes, inline surveys don't auto-close when submitted. The thank-you screen stays visible inside the container. Multiple inline surveys can be embedded on the same page.
You can also use data attributes:
<div id="survey-box"></div>
<script
src="https://embed.pollpe.com/sdk.js"
data-form-id="YOUR_SURVEY_ID"
data-mode="inline"
data-container="#survey-box"
data-height="600px">
</script>
Auto-Open
Set autoOpen: true to open the survey as soon as the script loads. Useful for post-purchase surveys or exit-intent triggers.
PollPe.open('FORM_ID', {
mode: 'popup',
autoOpen: true
});
You can also use data attributes on the script tag:
<script
src="https://embed.pollpe.com/sdk.js"
data-form-id="YOUR_SURVEY_ID"
data-mode="popup">
</script>
Async Loading
If you load the SDK with async or defer, use the command queue pattern to avoid race conditions:
<script>
window.PollPe = window.PollPe || { _q: [] };
PollPe.open = PollPe.open || function() { PollPe._q.push(arguments); };
PollPe.open('FORM_ID', { mode: 'popup', autoOpen: true });
</script>
<script src="https://embed.pollpe.com/sdk.js" async></script>
Queued calls are replayed automatically once the SDK loads.
Multiple Surveys
Only one overlay survey (popup, panel, or fullscreen) can be open at a time. Calling PollPe.open() with an overlay mode while one is already open will close the previous one and open the new one.
Inline surveys are independent -- you can have multiple inline surveys on the same page, and opening an overlay survey won't affect them.
User Interaction
| Action | Popup / Panel | Fullscreen | Inline |
|---|---|---|---|
| Click outside overlay | Closes | -- | -- |
| Press Escape key | Closes | Closes | -- |
| Click close button | Closes | Closes | -- |
| Submit survey | Fires onComplete, auto-closes | Fires onComplete, auto-closes | Fires onComplete, stays visible |