Skip to content

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.

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.

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:

AttributeDescription
planThe user’s current subscription tier.
roleTheir job function or permission level.
teamIdThe company or group they belong to.

For the full list of SDK options, see Identifying Users.

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.

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.