MedusaJS

Add Zigpoll to Your MedusaJS Storefront

MedusaJS is an open-source headless commerce platform built on Node.js. Since MedusaJS storefronts are fully custom (typically Next.js or Gatsby), adding Zigpoll is as simple as embedding a script tag in your storefront code.


What you'll need

  • Your Zigpoll Account ID (find it in Zigpoll → Settings → Installation)

  • Access to your MedusaJS storefront codebase (e.g., your Next.js project)


Step 1: Get your Zigpoll embed code

  1. Go to Settings → Installation.

  2. Copy your Account ID.


Step 2: Add the Zigpoll script to your storefront

Since MedusaJS storefronts are custom-built, you'll add the Zigpoll embed script directly in your storefront code. Below are examples for the most common setups.

Next.js storefront (App Router)

Open your root layout file (e.g., app/layout.tsx) and add the Zigpoll script:

Next.js storefront (Pages Router)

Add the script to your pages/_app.tsx:

Plain HTML / Other frameworks

If your storefront uses plain HTML or another framework, paste this in your HTML before the closing </body> tag:

Replace YOUR_ACCOUNT_ID with your actual Zigpoll Account ID.


Step 3: Configure display rules

Back in the Zigpoll dashboard, set your survey's Display Rules to control when and where surveys appear:

  • All pages — sitewide polls, exit intent, timed popups

  • Specific URLs — target checkout, product, or landing pages

  • Post-purchase — show surveys on your order confirmation page


(Optional) Post-purchase surveys with order data

To run post-purchase surveys on your MedusaJS order confirmation page, pass order metadata to Zigpoll. Add this script on your order confirmation/thank-you page:

This attaches the order ID, value, customer email, and line items to the survey response, making it easy to segment and analyze in Zigpoll.


Step 4: Verify the installation

  1. Start your MedusaJS storefront locally or deploy to staging.

  2. Open the site in an incognito/private window.

  3. Confirm your Zigpoll survey appears based on your display rules.


Tips

  • Use Zigpoll's preview mode to test display settings without publishing.

  • You can install multiple Zigpoll scripts with different Account IDs for different storefronts or environments.

  • For URL-based targeting, use Zigpoll's Display Rules — no code changes needed.

  • MedusaJS exposes order and customer data via its API; use this to enrich window.Zigpoll.metadata for richer survey analytics.


Troubleshooting

  • Survey not showing? Check your Zigpoll display rules and confirm the script loaded (look for main.js in your browser's Network tab).

  • Wrong pages? Adjust page targeting in Zigpoll's Display Rules or move the script to a specific page component.

  • Need help? Contact [email protected]envelope.

Last updated