documentUnloading (Web SDK)
The documentUnloading property allows you to use the browser’s sendBeacon method to send data to Adobe. This method is part of the browser’s Web APIs, not the JavaScript language itself. If a typical request takes too long, the browser can cancel the request. You can tell the Web SDK to use sendBeacon so that the request runs in the background after you navigate away from the page. Enable this property to help prevent data requests from getting canceled by the browser when unloading.
Web SDK uses sendBeacon only after a visitor identity is established. Before an identity is established (for example, on a new visitor’s first event), Web SDK sends the event to the Edge Network using fetch so that it can receive the identity in the response. Starting in version 2.36.1, these fetch requests use the keepalive option so that the browser finishes sending the request even if the visitor navigates away from the page.
Several browsers impose a limit of 64 KB to the amount of data that can be sent with sendBeacon at one time. The same limit applies to fetch requests that use keepalive. If the browser rejects the event because the payload is too large, the Web SDK falls back to using its normal transport method. Even if a given browser allows larger payloads, Adobe data collection servers truncate payloads down to 64 KB.
Set the documentUnloading boolean when running the sendEvent command. Its default value is false. Set this property to true if you want to use the sendBeacon method to send data to Adobe.
documentUnloading property is incompatible with the renderDecisions property. Avoid setting both properties to true simultaneously.alloy("sendEvent", {
"xdm": adobeDataLayer.getState(reference),
"documentUnloading": true
});
Validate events sent with documentUnloading validate
If the page navigates away before a sendBeacon request finishes, Chrome developer tools can show the request (type ping) as (canceled) even when the browser continues sending it. Requests sent using fetch with keepalive can show as canceled in the same way. This label alone does not establish whether data was lost.
Web SDK debug logs can’t confirm delivery either. Browsers don’t return a response for sendBeacon requests, so the log shows only that Web SDK sent the request using sendBeacon.
Open an inspection tool before reproducing navigation. Look for a captured server response or, in a connected Edge Trace/Assurance session, the incoming request at the Edge Network. See Aborted requests for the shared inspection workflow and its evidence limits. Confirmation of Edge receipt does not by itself establish downstream processing.
When events can be lost data-loss
The documentUnloading property can’t help with events that Web SDK hasn’t sent yet when the page unloads. For example, Web SDK holds events while consent is pending (see defaultConsent), or while it waits for an in-progress identity request to finish. In the second case, the debug log shows Delaying request while retrieving ECID from server.
Document unloading using the Web SDK tag extension
The Document will unload checkbox is available when configuring a Send event action when using the Web SDK tag extension.