Platform Integration Guide
Quick Summary: Connect your PEBL studies with external recruitment platforms like Prolific, MTurk, SONA, Qualtrics, and SurveyMonkey for seamless participant management and credit granting.
What You'll Learn
- How to integrate with popular recruitment platforms
- Setting up completion codes and redirects
- Using template variables for participant tracking
- Configuring auto-redirect vs. manual redirect
- Troubleshooting integration issues
Overview
The PEBL Online Platform integrates with external participant recruitment and survey platforms, allowing participants to:
- Start in the external platform (Prolific, MTurk, etc.)
- Complete your PEBL study
- Return automatically with a completion code
- Receive credit in the external platform
Template Variables
Use these variables in your completion codes and redirect URLs:
| Variable | Description | Example | ---------- | ------------- | --------- | {COMPLETIONCODE} | Generated completion code | PEBL-ABC123-X9Y2 | {PARTICIPANT} | Participant ID | SUBJ001 or 5 | {SESSION} | Session UUID | a1b2c3d4-... | {CHAIN} | Chain ID | CHAINxyz | {TOKEN} | Study token | STUDYABC | {TIMESTAMP} | Unix timestamp | 1730400000 | {RANDOM} | Random 16-char hex | A3F9D2E8... | Important: Platform variables (like {{%PROLIFICPID%}}) are NOT encoded when used in URLs, allowing the platform to replace them correctly.
Prolific IntegrationUse Case: Professional participant recruitment with built-in quality controls. Setup Steps1. Create Your Test ChainIn PEBL Online Platform:
2. Configure Completion SettingsCompletion Code Format (optional):
Redirect URL:
Callback URL: Leave empty (not needed) 3. Get Your Study URLYour chain URL will look like:
Note the 4. Create Prolific Study
BehaviorIf completion code format is set:
If completion code format is empty:
Best Practices
Amazon Mechanical Turk (MTurk)Use Case: Large-scale participant recruitment with flexible payment options. Setup Steps1. Configure Completion SettingsCompletion Code Format:
Redirect URL:
2. Create External HIT
https://yourschool.sona-systems.com/webstudycredit.aspx?experimentid=XXX&credittoken=YYY&surveycode={PARTICIPANT}
https://peblhub.online/runtime/chain-launcher.html?chain=CHAINxxx&token=STUDYxxx&participant=%%SURVEYCODE%%
Q-{PARTICIPANT}-{RANDOM}
https://yoursurvey.qualtrics.com/jfe/form/SVXXXXXXX?peblcode={COMPLETIONCODE}&peblparticipant={PARTICIPANT}
Thank you! Your completion code is ${e://Field/peblcode}
SM-{PARTICIPANT}
https://www.surveymonkey.com/r/XXXXXXX?code={COMPLETIONCODE}&participant={PARTICIPANT}
CUSTOM-{PARTICIPANT}-{TIMESTAMP}
https://your-platform.com/study-complete?session={SESSION}&code={COMPLETIONCODE}&participant={PARTICIPANT}
https://your-platform.com/api/grant-credit json { "sessionid": "uuid-here", "participantid": "PARTICIPANT123", "chainid": "CHAINxyz", "tokenid": "STUDYABC", "completioncode": "CUSTOM-PARTICIPANT123-1730000000", "status": "completed", "timestamp": "2025-10-31T12:00:00Z" }
php // Your endpoint: /api/grant-credit $data = jsondecode(filegetcontents('php://input'), true);
if ($data['status'] === 'completed') { // Grant credit to participant grantCredit( $data['participantid'], $data['completioncode'] ); // Log completion logCompletion($data); // Respond httpresponsecode(200); echo jsonencode(['success' => true]); }
| Platform | Best For | Credit Method | Code Needed? | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| <strong>Prolific</strong> | Professional recruitment | Automatic via URL | Optional | ||||||||||||||||||||||||||||||||||||
| <strong>MTurk</strong> | Large-scale recruitment | External submit | Required | ||||||||||||||||||||||||||||||||||||
| <strong>SONA</strong> | University pools | Auto credit grant | No | ||||||||||||||||||||||||||||||||||||
| <strong>Qualtrics</strong> | Surveys + tests | Manual or piped text | Optional | ||||||||||||||||||||||||||||||||||||
| <strong>SurveyMonkey</strong> | Simple surveys + tests | Manual variables | Optional | ||||||||||||||||||||||||||||||||||||
| <strong>Custom</strong> | Full control | Your implementation | Your choice |
<h2>Troubleshooting</h2>
<h3>Redirect Not Working</h3>
<strong>Causes</strong>:
- Incorrect URL format
- Missing required variables for platform
- Browser blocking redirect
<strong>Solutions</strong>:
- Test the redirect URL directly in browser
- Check browser console (F12) for errors
- Verify all template variables are present
- Try different browser (some block redirects)
<strong>Causes</strong>:
- Code not included in redirect URL
- Platform not configured to capture URL parameters
- Variable name mismatch
<strong>Solutions</strong>:
- Verify {COMPLETION<em>CODE}
in redirect URL - Check platform's custom variable/embedded data settings
- Ensure variable names match (case-sensitive)
<strong>Causes</strong>:
- Redirect URL incorrect
- Completion code not valid format for platform
- Platform API changed
<strong>Solutions</strong>:
- Test complete flow yourself as participant
- Check platform's current API documentation
- Verify credit granting settings in platform
- Use callback URL for more reliable tracking
<strong>Causes</strong>:
- Variable formatted incorrectly for platform
- URL encoding breaking platform variable format
<strong>Solutions</strong>:
- Prolific: Use {{%PROLIFIC</em>PID%}}
(double braces, percent signs) - MTurk: Use {{workerId}}
and{{assignmentId}}(double braces) - SONA: Use %%SURVEY<em>CODE%%
(double percent signs) - Qualtrics: Use ${e://Field/ResponseID}
(dollar sign, braces)
<h2>Security Considerations</h2>
<h3>Best Practices</h3>
- <strong>Never include sensitive credentials in URLs</strong>
- Use environment variables or config files
- Keep API keys server-side only
- <strong>Use HTTPS for all callback URLs</strong>
- Encrypt data in transit
- Prevent man-in-the-middle attacks
- <strong>Validate completion codes on your server</strong>
- Don't rely solely on client-side redirect
- Verify code format and uniqueness
- Check timestamp isn't too old (prevent replay)
- <strong>Use callback URLs for credit granting</strong>
- More secure than client-side redirect
- Participant can't manipulate server-to-server communication
- Verify before granting credit
<h3>Example: Validation Logic</h3> php function validateCompletionCode($code, $participant, $timestamp) { // Check format if (!pregmatch('/^STUDY-[A-Z0-9]+-[A-F0-9]+$/', $code)) { return false; }
// Check timestamp isn't too old (within 24 hours) $maxAge = 86400; // 24 hours in seconds if (time() - $timestamp > $maxAge) { return false; }
// Check code hasn't been used before if (codeAlreadyUsed($code)) { return false; }
return true; } ``
Testing Your Integration
Pre-Launch Checklist
- [ ] Test complete flow as participant (start to finish)
- [ ] Verify completion code displays correctly
- [ ] Check redirect works in multiple browsers
- [ ] Confirm credit/payment granted in external platform
- [ ] Test with platform's sandbox/test mode if available
- [ ] Verify callback receives data correctly (if used)
- [ ] Check data matches between PEBL and external platform
- [ ] Test failure scenarios (participant closes browser mid-study)
- [ ] Document the working configuration for future studies
Common Test Scenarios
- Happy path: Complete study normally
- Early exit: Close browser mid-study, return later
- Multiple attempts: Try to complete twice with same code
- Different browsers: Test on Chrome, Firefox, Safari
- Mobile: Test on mobile devices if participants will use them
Platform-Specific Resources
- Prolific: https://researcher-help.prolific.com
- MTurk: https://requester.mturk.com/help
- SONA: Contact your institution's SONA administrator
- Qualtrics: https://www.qualtrics.com/support/
- SurveyMonkey: https://help.surveymonkey.com
Warning: Platform APIs and requirements change over time. Always verify current requirements in the platform's official documentation before launching your study.
Related Topics
- Creating Test Chains - Build batteries with completion pages
- Participant Codes - Understanding participant ID systems
- Getting Started - Basic study setup
Need more help? Contact your platform's support team or consult their official documentation for the most current integration requirements.