Website Widget
No backend required
Let your customers get coverage right on your website with our JavaScript widget.
Paste and go
One script tag and one init call. No npm package and no server code.
Your branding
Colors, fonts and products come from your widget settings in the partner portal.
Mobile friendly
The widget resizes to fit phones, tablets and desktops.
Works anywhere
Any website or site builder, plus React, Next.js and Vue.
Floating or inline
Show a button in the corner of the page, or place the widget inside your page.
Events you can track
Callbacks fire when the widget loads, opens or closes, when a quote starts or completes and when coverage is purchased.
Before you start
- Sign in to the partner portal and open your microsite page (/partner/microsite).
- Create a widget if you don't have one, and set its colors and products.
- Copy your widget ID and partner ID into the code below, in place of
YOUR_WIDGET_IDandYOUR_PARTNER_ID. Signed in to the help chat? Ask the assistant for widget code and it fills these in for you.
Any website (HTML)
Paste this just before the closing </body> tag. In WordPress, Squarespace, Wix, Webflow or Shopify, use the site builder's custom code or HTML block. The script lives at https://dailyeventinsurance.com/widget/v1/dei-widget.js.
Floating button
<!-- Daily Event Insurance widget: paste before </body> -->
<script src="https://dailyeventinsurance.com/widget/v1/dei-widget.js"></script>
<script>
DailyEventWidget.init({
widgetId: 'YOUR_WIDGET_ID',
partnerId: 'YOUR_PARTNER_ID',
mode: 'floating',
position: 'bottom-right',
autoOpen: false
});
</script>Inside your page
<!-- Daily Event Insurance widget: paste before </body> -->
<div id="dei-widget"></div>
<script src="https://dailyeventinsurance.com/widget/v1/dei-widget.js"></script>
<script>
DailyEventWidget.init({
widgetId: 'YOUR_WIDGET_ID',
partnerId: 'YOUR_PARTNER_ID',
mode: 'inline',
container: '#dei-widget',
autoOpen: false
});
</script>React
A small component that loads the script and starts the widget. Render it once on the pages where the widget should appear.
import { useEffect } from 'react'
// Loads the Daily Event Insurance widget script and starts the widget.
// No npm package needed.
const DEI_WIDGET_SRC = 'https://dailyeventinsurance.com/widget/v1/dei-widget.js'
type DeiWidget = { destroy: () => void }
declare global {
interface Window {
DailyEventWidget?: { init: (config: Record<string, unknown>) => DeiWidget }
}
}
export function DailyEventInsuranceWidget() {
useEffect(() => {
let widget: DeiWidget | undefined
const start = () => {
widget = window.DailyEventWidget?.init({
widgetId: 'YOUR_WIDGET_ID',
partnerId: 'YOUR_PARTNER_ID',
mode: 'floating',
position: 'bottom-right',
autoOpen: false,
})
}
let script = document.querySelector<HTMLScriptElement>(`script[src="${DEI_WIDGET_SRC}"]`)
if (window.DailyEventWidget) {
start()
} else {
if (!script) {
script = document.createElement('script')
script.src = DEI_WIDGET_SRC
script.async = true
document.body.appendChild(script)
}
script.addEventListener('load', start)
}
return () => {
script?.removeEventListener('load', start)
widget?.destroy()
}
}, [])
return null
}Next.js (App Router)
The same component as a client component. Import it into any page or layout.
// components/DailyEventInsuranceWidget.tsx
'use client'
import { useEffect } from 'react'
// Loads the Daily Event Insurance widget script and starts the widget.
// No npm package needed.
const DEI_WIDGET_SRC = 'https://dailyeventinsurance.com/widget/v1/dei-widget.js'
type DeiWidget = { destroy: () => void }
declare global {
interface Window {
DailyEventWidget?: { init: (config: Record<string, unknown>) => DeiWidget }
}
}
export function DailyEventInsuranceWidget() {
useEffect(() => {
let widget: DeiWidget | undefined
const start = () => {
widget = window.DailyEventWidget?.init({
widgetId: 'YOUR_WIDGET_ID',
partnerId: 'YOUR_PARTNER_ID',
mode: 'floating',
position: 'bottom-right',
autoOpen: false,
})
}
let script = document.querySelector<HTMLScriptElement>(`script[src="${DEI_WIDGET_SRC}"]`)
if (window.DailyEventWidget) {
start()
} else {
if (!script) {
script = document.createElement('script')
script.src = DEI_WIDGET_SRC
script.async = true
document.body.appendChild(script)
}
script.addEventListener('load', start)
}
return () => {
script?.removeEventListener('load', start)
widget?.destroy()
}
}, [])
return null
}Vue 3
A single-file component that loads the script on mount and removes the widget on unmount.
<!-- DailyEventInsuranceWidget.vue: loads the Daily Event Insurance widget script. No npm package needed. -->
<template>
<span></span>
</template>
<script setup>
import { onMounted, onBeforeUnmount } from 'vue'
const DEI_WIDGET_SRC = 'https://dailyeventinsurance.com/widget/v1/dei-widget.js'
let widget
let script
function start() {
widget = window.DailyEventWidget.init({
widgetId: 'YOUR_WIDGET_ID',
partnerId: 'YOUR_PARTNER_ID',
mode: 'floating',
position: 'bottom-right',
autoOpen: false,
})
}
onMounted(() => {
if (window.DailyEventWidget) {
start()
return
}
script = document.querySelector(`script[src="${DEI_WIDGET_SRC}"]`)
if (!script) {
script = document.createElement('script')
script.src = DEI_WIDGET_SRC
script.async = true
document.body.appendChild(script)
}
script.addEventListener('load', start)
})
onBeforeUnmount(() => {
if (script) script.removeEventListener('load', start)
if (widget) widget.destroy()
})
</script>Options
widgetIdRequired. Your widget's ID from the partner portal.
partnerIdYour partner ID from the partner portal.
mode'floating' (default) or 'inline'.
positionFloating only: 'bottom-right' (default) or 'bottom-left'.
containerInline only: a CSS selector for the element to place the widget in, such as '#dei-widget'.
autoOpentrue opens the widget as soon as it loads. Default false.
zIndexStacking order for the floating widget. Default 10000.
Callbacks
Use these to track the widget, quotes and purchases in your own analytics:
DailyEventWidget.init({
widgetId: 'YOUR_WIDGET_ID',
partnerId: 'YOUR_PARTNER_ID',
onReady: function (data) { /* widget loaded: data.widgetId */ },
onOpen: function () { /* widget opened */ },
onClose: function () { /* widget closed */ },
onQuoteStart: function (data) { /* customer started a quote */ },
onQuoteComplete: function (quote) { /* quote is ready */ },
onQuoteError: function (error) { /* error.code, error.message */ },
onPaymentStart: function (data) { /* customer started checkout */ },
onPolicyPurchased: function (policy) { /* coverage purchased */ },
onPaymentError: function (error) { /* error.code, error.message */ },
onError: function (error) { /* widget settings couldn't load */ }
});Good to know
- The widget needs no API key. Never put an API key in website code.
- Change colors, fonts and products in the portal; your site picks up the change without new code.
- Payment happens inside the widget, so card details never touch your website.
- Signed in to the help chat? Ask the assistant to check your setup; it reports when your widget last loaded.
Need help with installation?
Email us at support@dailyeventinsurance.com. Hours: Monday-Friday, 9am-5pm PT.