Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!

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

 

3 Replies

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.

Avatar

Community Advisor

Hi @JpVe1 

aside from the answer before (that sounds strangely ChatGPT-generated, but that is maybe just my impression), do you use the Web SDK extension to send the event from Adobe Launch or custom code?

I would always go with the extension, there are a lot of pitfalls along the way when you try to rely on custom code too much (speaking from experience).

If the problems stays, I would reach out to support.

Cheers from Switzerland!


Avatar

Level 1

Thanks @Roshanchauhan and @bjoern__koth 

The tracking (custom code) was done 2 years back so its probably due for a refactor with the alloy web SDK. Currently it uses the generated launch external script per environment and then calls the _satellite.track(...) property on the window ... and all this is inside an Angular pwa app. 

JpVe1_0-1734688425052.png

 

My suspicion is that when our application loads, because it is a cached pwa, we do a version check. If there is an update we clear the cache and force a reload on the next navigation event to get the newer js chunks. I see the launch script attaches a click event listener to the document [ActivityTracker] which seems to trigger the error when the reload navigation event is triggered - most likely because the document is in a state of reload with no cache - aiy the joys.

 

I am going to redo with the web sdk and also add in the async and error handling to see if that makes the issue go away. 

 

Thanks guys, will let you know how it goes.