Third Party Library via HTML

Hey folks, thanks for the time to read my post.

I have been struggling to integrate a third party pixel to track completed orders for an affiliate network.

My thought process is to capture the order details from the Thank You Page, which I have done, and send the order object to an embedded HTML element on the same page.
The HTML element has a head and body script that has to fire in sequence, including a call to a third party library to post the order object/array.

I can’t get it to work, even using a timeout between scripts; it seems like the body script is firing prior to the head script and it’s out of order.

Anyone can shed some light on this? Below is my HTML code.

Ok, first things first: this is not a Corvid-related problem, the html-element is basically a “if it doesn´t work, goto Stackoverflow”-thing. Kinda. I´ve been wrestling with this html-thing ages ago, and I know the above is not quite true. What might happen is this: the timing problem. You do not share the calliing code, so I can´t be sure, but it just could be that, when you postMessage() from your page, the html-element is not ready to receive yet, so data goes out into cyberspace, never to be heard of again. Then, finally, the element loads and the body loads, there is no message (gone), so the body script is executed. Not first, but as the only one. Have a look at an old contribution here : https://girizano.wixsite.com/codecorner/post/html-component-not-running-in-publish-mode-google-sheets-example
Good luck.