Install the script
To show surveys in your product, add the Pulseahead JavaScript snippet to your application. The script initializes the widget and handles targeting, triggering, and response collection automatically.
Add the snippet
Section titled “Add the snippet”Open Embed Code in the Pulseahead dashboard sidebar, copy the installation script, and paste it into the <head> section of your HTML. That script already includes your project id and the correct script URL for your workspace.
For reference, it follows this shape (your copied version has real values filled in):
<script type="text/javascript"> window.pulseahead = window.pulseahead || function () { (window.pulseahead.q = window.pulseahead.q || []).push(arguments); }; window.pulseahead("config", { projectId: "YOUR_PROJECT_ID" }); (function () { var script = document.createElement("script"); script.src = "https://www.pulseahead.com/embed.js"; script.async = true; document.head.appendChild(script); })();</script>If you assemble the snippet yourself, use the same projectId and script.src as on the Embed Code page.
Identify users (recommended)
Section titled “Identify users (recommended)”By default, Pulseahead tracks responses anonymously. To associate feedback with specific users in your system, add an identify call after the base snippet. Call this once you know who the logged-in user is, typically after your authentication flow completes.
window.pulseahead("identify", "USER_ID_FROM_YOUR_SYSTEM", { plan: "pro", role: "admin", signupDate: "2024-01-15",});The second argument is your internal user ID. The third argument is an optional object of attributes you want to use for targeting or filtering. Common attributes include:
| Attribute | Description |
|---|---|
plan | The user’s current subscription tier. |
role | Their job function or permission level. |
teamId | The company or group they belong to. |
For the full list of SDK options, see Identifying Users.
Notes for specific setups
Section titled “Notes for specific setups”Single Page Applications (SPAs)
Section titled “Single Page Applications (SPAs)”If you use React, Vue, Next.js, or another SPA framework, load the snippet globally so it is only initialized once. In Next.js, add it to _document.js or use the <Script> component in your root layout. In a Vite or Create React App project, add it to your index.html.
The script listens for route changes automatically. You do not need to re-initialize it when the URL changes.
Script placement
Section titled “Script placement”Placing the snippet in <head> is recommended over placing it at the end of <body>. Loading it early ensures Pulseahead is ready before a user interacts with a feature that has a manual trigger attached.
Next steps
Section titled “Next steps”- Launch your first survey — go from snippet to a live survey in the dashboard.
- Core concepts — how surveys, targeting, appearance, and identity fit together.
- Script & Initialization — deeper SDK reference for the same snippet.
- Survey response alerts — notify your team in Slack when important answers come in.