engagepop
v0.1.0
Published
EngagePop web SDK — popups, social proof, feed & web push for web apps. Typed wrapper around the EngagePop widget.
Maintainers
Readme
EngagePop web SDK
Popups, social-proof toasts, notification feed & web push for web apps — engagepop.com.
This package is a typed, framework-friendly wrapper around the same EngagePop
widget the <script> snippet loads. The widget itself is served from the
EngagePop CDN, so it adds zero weight to your bundle and widget updates
reach your site without a package bump.
npm install engagepopQuick start
import { init, identify, track } from "engagepop";
init({ siteKey: "ep_..." }); // site key from Dashboard → Installation
// Optional: who is this visitor? (stays in THEIR browser — never sent to us)
identify({ email: "[email protected]", plan: "pro" });
// Optional: feed social proof / the live feed
track("purchase", { product: "Pro plan", name: "Ada", location: "Berlin" });React / Next.js
import { EngagePopProvider } from "engagepop/react";
export default function App({ children }) {
return <EngagePopProvider siteKey="ep_...">{children}</EngagePopProvider>;
}import { useEngagePop } from "engagepop/react";
function BuyButton() {
const ep = useEngagePop();
return <button onClick={() => ep.track("purchase", { product: "Pro" })}>Buy</button>;
}Both entry points are SSR-safe: on the server every call is a no-op, and the
provider is a client component ("use client"), so it drops into a Next.js
App Router layout as-is.
API
| Function | What it does |
|---|---|
| init({ siteKey, cdnUrl?, serviceWorkerPath? }) | Loads the widget. Idempotent; resolves when loaded. |
| identify(attrs) | Sets visitor attributes for {{vars}} and audience targeting. Values are stored only in the visitor's browser (localStorage) and never sent to EngagePop. null deletes a key. Safe before load. |
| reset() | Clears identified attributes — call on logout. |
| track(type, props?) | Feeds an activity event ("purchase", "signup", …) to social-proof toasts and the dashboard live feed. Buffered until the widget loads. |
| convert({ value?, order? }) | Reports a conversion on your thank-you page; attributed to the last campaign the visitor engaged with (7-day window). |
| subscribePush() | Prompts for notification permission and subscribes the browser to your site's web push. Requires your service worker at serviceWorkerPath (default /sw.js) on your origin. |
| pushSupported() | Whether this browser can do web push. |
| ready() | Promise that resolves once the widget has loaded. |
Notes
- Already using the snippet? The SDK detects an existing widget and won't load it twice — you can adopt the npm package incrementally.
- SPA routing: the widget evaluates page targeting when it loads (same as the snippet). Campaigns targeted at specific paths match the URL at load time, not on client-side route changes.
- Ad blockers:
init()rejects if the script is blocked. All other calls are safe no-ops in that state — never gate your app on the widget.
License
MIT
