Expand my Community achievements bar.

Identity cookie and sendEvent errors (Uncaught in promise)

Avatar

Level 1

Our ecommerce website is getting substantial reports in dataDog logs (831 in the past day) for:

ERROR Error: Uncaught (in promise): Error: Identity cookie not found.


and 

ERROR Error: Uncaught (in promise): TypeError: [alloy] [DataCollector] An error occurred while executing the sendEvent command.
 

JpVe1_0-1734600997468.png

It does not happen for everyone.

Seems to be an issue loading in the adobe launch script or the actual sendEvent - would placing it an async block and adding try catch around the sendEvent call hide / fix the issue?.

JpVe1_1-1734601578518.png

 

1 Reply

Avatar

Level 4

Hi @JpVe1 ,

To resolve the "Identity cookie not found" and "sendEvent errors" in Adobe Launch, follow these steps:

  1. Check Identity Cookie: Ensure the identity cookie is available before calling sendEvent. Use fallback or retry logic to handle cases where it's not set yet.

  2. Use Async Block & Try-Catch: Wrap the sendEvent call in an async block with try-catch for error handling:

     

 

async function sendEventAsync() {
    try {
        await alloy.sendEvent(...);
    } catch (error) {
        console.error('sendEvent failed:', error);
    }
}
sendEventAsync();

 

  • Retry Logic: Implement retry logic if the identity cookie or SDK is unavailable:

     

 

function sendEventWithRetry(retries = 3) {
    if (window.adobeDataLayer) {
        try { alloy.sendEvent(...); } catch (e) { console.error('sendEvent failed:', e); }
    } else if (retries > 0) {
        setTimeout(() => sendEventWithRetry(retries - 1), 1000);
    }
}
sendEventWithRetry();

 

  • Ensure Proper SDK Initialization: Confirm that Adobe Alloy/SDK is fully initialized before calling sendEvent.

  • Test Across Browsers: Ensure cookie and network settings aren’t blocking the identity cookie, especially in privacy-conscious browsers.

This approach should minimize errors related to cookie loading and event sending.