# Bigcommerce

## Add Zigpoll to BigCommerce with Script Manager

Want Zigpoll running on your BigCommerce store without installing an app? Use BigCommerce’s built-in **Script Manager** to paste a small embed snippet. This takes 5–10 minutes and works across any Stencil theme.

***

### What you’ll need

* Your Zigpoll **Account ID** (find it in Zigpoll → Settings → Installation).
* BigCommerce store admin access.

***

### Step 1: Open Script Manager

1. In BigCommerce, go to **Storefront → Script Manager**.
2. Click **Create a Script**.

***

### Step 2: Configure the script

Fill the form like this:

* **Name:** `Zigpoll Embed`
* **Description:** `Loads Zigpoll widget on site` (optional)
* **Location on page:** **Footer** (recommended)
* **Select pages where script will be added:**
  * **All Pages** for a sitewide survey/prompt, **or**
  * **Order Confirmation Page** for post-purchase surveys only
* **Script type:** **Script** (the “script contents” option, not a URL)

***

### Step 3: Paste the Zigpoll embed code

In **Script**, paste:

```html
<script type='application/javascript'>
  ;(function () {
    window.Zigpoll = {
      accountId: 'YOUR_ACCOUNT_ID'
    };

    var script = document.createElement("script");
    script.type = "text/javascript";
    script.charset = "utf-8";
    script.src = "//cdn.zigpoll.com/static/js/main.js";
    script.async = true;

    document.head.appendChild(script);
  }());
</script>
```

Click **Save**.

***

### Step 4: Verify on your storefront

1. Open your storefront in a new tab (not logged into admin).
2. Hard-refresh the page.
3. You should see your Zigpoll survey according to how you’ve targeted it (sitewide or post-purchase).

***

### Targeting options (what to choose)

* **All Pages:** Great for on-site polls (exit intent, timed popups, specific pages).
* **Order Confirmation Page:** Ideal for **post-purchase** NPS/CSAT, product-fit, or attribution surveys. (Choose this page in Script Manager to avoid showing surveys to non-buyers.)

Tip: You can create **multiple scripts** if you want separate behavior (e.g., one sitewide + one order confirmation).

***

### (Optional) Pass order info on the confirmation page

If you install the script only on the **Order Confirmation Page**, you can attach touch metadata that’s commonly present without depending on a specific theme. This information helps segment responses in Zigpoll and provides additional data for future analysis.

```html
<script>
// Fetch API to get product, order and customer details
var orderId = '{{ checkout.order.id }}';
var api = '/api/storefront/orders/'+ orderId;

fetch(api)
.then((res) => res.json())
.then((order)=>{
 
var orderValue = order.orderAmount;
var email = order.billingAddress.email;
var phone = order.billingAddress.phone;
var firstName = order.billingAddress.firstName;
var lastName = order.billingAddress.lastName;
var city = order.billingAddress.city;
var region = order.billingAddress.stateOrProvince;
var country = order.billingAddress.country;
var countryCode = order.billingAddress.countryCode;
var address = order.billingAddress.address1+' '+order.billingAddress.address2;
var postalCode = order.billingAddress.postalCode;
var lineItems = [];

if (order.lineItems) {
  Object.keys(lineItems).forEach(function (key) {
    lineItems[key].forEach(function (items) {
      items.forEach(function (item) {
        lineItems.push(item.name);
      })
    })
  })

  if (lineItems.length) {
    lineItems = lineItems.join(', ');
  }
}
// Prepare Zigpoll Variables
var accountId = 'YOUR_ACCOUNT_ID';
window.Zigpoll = {
  accountId: accountId
};

window.Zigpoll.user = {
  id: email,
  metadata: {
    email: email,
    phone: phone,
    name: [firstName, lastName].join(' ').trim(),
    city: city,
    region: region,
    country: country,
    countryCode: countryCode,
    address: address,
    postalCode: postalCode
  }
}

window.Zigpoll.metadata = {
  orderValue: orderValue,
  orderId: orderId,
  lineItems: lineItems
}

var precursorEvent = window.Zigpoll.precursorEvent || {};
precursorEvent.type = 'bigcommerce-order-placed';
precursorEvent.uniqueId = ''+orderId;

// Load Zigpoll Script
var script = document.createElement("script");
script.type = "text/javascript";
script.charset = "utf-8";
script.src = '//cdn.zigpoll.com/static/js/main.js';
document.head.appendChild(script);

});
</script>
```
