Send and Verify the First Event
Initialization automatically queues a page_view. Send a product view as the first explicit commerce event, then flush the queue so you do not need to wait for the default interval.
Send a product view
- SDK is loaded
- Script is still loading
Run this after window.upsurge.isInitialized() returns true:
window.upsurge.trackProductView({
product_id: 'SKU-TRAIL-123',
product_name: 'Trail Runner',
product_category: 'Shoes',
product_price: 129.0,
currency: 'USD',
});
await window.upsurge.flush();
Queue both calls in order. The SDK replays them after initialization:
window.UpsurgeQueue = window.UpsurgeQueue || [];
window.UpsurgeQueue.push([
'trackProductView',
{
product_id: 'SKU-TRAIL-123',
product_name: 'Trail Runner',
product_category: 'Shoes',
product_price: 129.0,
currency: 'USD',
},
]);
window.UpsurgeQueue.push(['flush']);
Use stable catalog IDs. Monetary fields are numeric values in the stated currency; use one representation consistently across your integration.
Verify the network response
- Open browser developer tools and select Network.
- Filter for
events/batch. - Confirm the request URL uses your Upsurge origin, not the storefront origin.
- Confirm the SDK first bootstraps with
site_id, then sends the batch withAuthorization: Bearer <runtime_token>and no API key. - Inspect the response.
A fully successful batch returns 201 and a body shaped like this:
{
"success": true,
"data": {
"processed": 2,
"succeeded": 2,
"failed": 0,
"results": [
{
"event_id": "evt_example_1",
"timestamp": "2026-07-11T20:00:00.000Z",
"success": true
},
{
"event_id": "evt_example_2",
"timestamp": "2026-07-11T20:00:00.010Z",
"success": true
}
]
}
}
207 means the request was accepted but at least one event failed. Read each item in results before treating the batch as successful.
Verify Analytics
- Open Dashboard → Analytics.
- Choose a date range that includes today.
- Select the connected site, or leave the site filter on all sites.
- Select the first-party data source.
- Refresh the page after the ingestion request succeeds.
The event totals and activity timeline should include the new activity. Depending on the analytics deployment, aggregation may take a short time after the ingestion response.
Completion checklist
- The core script returns
200. window.upsurge.isInitialized()returnstrue.- The batch request targets the Upsurge origin.
- The batch reports no failed events.
- Analytics shows activity for the correct site and date range.
Next, implement the full commerce event set or start your first overlay or chatbot.