Skip to main content
Version: Current platform

SDK Configuration

Pass configuration in the queued init call or to new window.Upsurge(config).

Required and routing options​

OptionTypeDefaultDescription
siteIdstring—Public site identifier. Required. The SDK exchanges it for an origin-bound runtime token.
baseUrlstringwindow.location.originUpsurge application/API origin. Production integrations must set https://api.upsur.ge.
assetBaseUrlstringthe core's version folder when the core loads from cdn.upsur.ge, otherwise ${baseUrl}/sdkFolder the SDK loads its feature bundles and fonts from. Leave it unset unless a script loader hides the SDK's URL; then set it to the folder of the pinned core's release, for example https://cdn.upsur.ge/sdk/2.6.0, never https://cdn.upsur.ge/sdk itself. See Pin a version.
conversionEventType'purchase' | 'checkout_complete''purchase'Event that receives is_conversion: true.
profileTokenstring—Optional short-lived, consent-gated storefront profile token minted by your trusted server. It is kept in memory only; rotate it with setProfileToken().

Queue and retry options​

OptionTypeDefaultDescription
batchSizenumber100Events that trigger an immediate batch flush. The ingestion API accepts at most 100 events per batch.
flushIntervalnumber10000Milliseconds between scheduled flushes.
maxQueueSizenumber1000Maximum queued events before overflow handling.
maxRetriesnumber3Retries for network and server failures.
retryDelaynumber1000Initial retry delay in milliseconds.
retryBackoffnumber2Exponential retry multiplier.
sessionTimeoutnumber1800000Inactivity in milliseconds before a new session.

Client errors and rate-limit responses are not retried automatically.

Capture and privacy options​

OptionTypeDefaultDescription
autoTrackPageViewsbooleantrueCapture the initial page view.
autoTrackSpaNavigationbooleantrueCapture History API navigation and refresh page-targeted overlays.
autoTrackEngagementSummariesbooleantrueEmit one bounded dwell, scroll, and interaction summary per page lifecycle.
respectDoNotTrackbooleanfalseDisable tracking when the browser advertises DNT.
enableFingerprintingbooleanfalseOpt in to device fingerprint generation.
debugbooleanfalseWrite diagnostic messages to the console.

Partner attribution options​

Partner attribution is off until partnerAttribution.mode is set.

OptionTypeDefaultDescription
mode'disabled' | 'advertiser' | 'publisher''disabled'Capture inbound advertiser traffic or explicitly track publisher outbound clicks.
attributionWindowDaysnumber30Eligible lookback, clamped to 1–90 days.
maxTouchChainLengthnumber20First-party chain cap, clamped to 1–20 touches.
outboundAllowedHostsstring[][]Exact hosts accepted by publisher URL helpers.
autoDecorateOutboundLinksbooleanfalseDecorate and track only explicitly marked publisher anchors.
voucherMappingsobject{}Merchant-owned voucher code to provider/partner mappings.
partnerAttribution: {
mode: 'advertiser',
attributionWindowDays: 30,
maxTouchChainLength: 20,
voucherMappings: {
CREATOR10: { provider: 'awin', partnerId: '12345' },
},
}

Advertiser mode automatically detects AWIN awc and CJ cjevent on initialization. Provider IDs, publisher references, partner IDs, sub-IDs, and vouchers remain distinct. Arbitrary unmapped voucher query values are ignored.

Advertiser mode also resolves eligible partner-experiment assignments before campaign modules load. Publisher automatic decoration requires exact allowlisted hosts and anchors marked with data-upsurge-partner-provider plus data-upsurge-click-reference.

Revenue attribution options​

Store revenue attribution is off unless the site enables it. Consent is denied until you supply it.

OptionTypeDefaultDescription
revenueAttribution.enabledbooleanfalseCapture the signed journey token that commerce integrations attach to carts and orders.
revenueAttribution.consent.analyticsbooleanfalseWithout analytics consent, only session-scoped state is retained.
revenueAttribution.consent.advertisingbooleanfalseAdvertising consent for attribution persistence.

Update consent at runtime with setAttributionConsent({ analytics, advertising }).

Workflow command options​

Workflows can show an overlay, open a chatbot, or refresh recommendations in the visitor's browser. See Run a campaign in the visitor's browser.

OptionTypeDefaultDescription
workflowCommands.enabledbooleantruePoll for site-scoped workflow commands. Polling does no work when no commands exist.
workflowCommands.pollingIntervalMsnumber15000Poll interval, clamped to 5–60 seconds.
workflowCommands.consent.marketingbooleanfalseAllow marketing-purpose commands.
workflowCommands.consent.personalizationbooleanfalseAllow personalization-purpose commands.

Update consent at runtime with setWorkflowCommandConsent().

What the chat widget reads from the page​

The chat widget needs no options of its own, but it reads these from your storefront page:

SourceWhat it is for
<html lang> (else the browser language)The widget's language: English, Spanish, French or German; anything else shows English. The welcome and the assistant's replies follow it too.
<meta name="upsurge:page"> and <meta name="upsurge:product">What the page is, for stores whose URLs don't say it, such as /p/123 or product.html?id=123. upsurge:page is home, product, collection, cart, checkout, search or other, and wins over the URL; any other value is ignored. upsurge:product is your Upsurge product ID or your store's product ID; on its own it means a product page. The product line and product suggestions appear only when Upsurge finds that product in your catalog. A page with either tag is described by its tags alone. Needs SDK 3.0.2 or later.
The first element with a data-product-id attributeThe product the welcome and the assistant talk about, on product pages whose URL doesn't name it and that have neither tag. Use your Upsurge product ID or your store's product ID. Shopify /products/<handle> and WooCommerce /product/<slug> pages don't need it, and their URL wins over the attribute. On a page whose URL isn't a product page, the attribute is ignored: it may belong to a cart drawer or a recommendation.
The cart from commerce events or setCartContext()Sent only from cart and checkout pages: pages tagged cart or checkout, or untagged /cart and /checkout pages. Upsurge checks every item against your catalog. A cart it cannot use, for example one with more than 20 items, is left out; the chat still works.

For a product page whose URL doesn't name the product, add both tags to the page's <head>. For a cart or checkout page, add <meta name="upsurge:page" content="cart"> or content="checkout".

<meta name="upsurge:page" content="product">
<meta name="upsurge:product" content="prod_123">

Put the tags in the page before the Upsurge SDK starts, in the HTML or from your script before you call init. The widget fetches its welcome when the shopper first reaches for the chat, so tags added later miss the welcome.

The widget asks for its welcome only when a shopper opens the chat, or points at, focuses or touches the launcher. It never asks at page load.

Callbacks​

OptionSignatureRuntime status
onEventQueued(event) => voidCalled after an event enters the queue.
onEventSent(event) => voidCalled once for every event accepted by batch ingestion. Failed events are requeued without invoking it.
onError(error) => voidCalled for transport or runtime errors handled by the SDK.

Production-oriented example​

window.UpsurgeQueue = window.UpsurgeQueue || [];
window.UpsurgeQueue.push([
'init',
{
siteId: 'site_replace_me',
baseUrl: 'https://api.upsur.ge',
conversionEventType: 'purchase',
batchSize: 50,
flushInterval: 5000,
autoTrackPageViews: true,
autoTrackSpaNavigation: true,
respectDoNotTrack: true,
enableFingerprinting: false,
onError(error) {
console.error('Upsurge SDK error', error);
},
},
]);

Do not pass the internal preloadedOverlays or preloadedChatbots test/demo options in a production storefront integration.