Javascript, WIX form -> Refersion

We are trying to push a registration from this page into Refersion. Code below. The first bit works ok, where we are tracking a page visit.

However, the second code is not working i.e.

Here are the problems:
1- I have tried putting it in the top of body, as suggested, but I am unable use the tags to automatically fetch “First Name”, “Last Name”, “EMAIL”, and date and/or time stamps that I wanna use for “ORDERNO”. So I need to know if it is possible in Wix to automatically fetch the unique data that the user/lead has filled into the form to this code?
2- I am trying to add the code via analytics section under settings and I assume that is where this code must be added. Am I right? Or should it be added on the desired page as custom HTML element?
3- I even tried using test order number, name, and email, but it still does not reflect in the affiliate panel. Does this mean that the code has some error?
The second code I have mentioned is actually from the Refersion support.
Here’s the complete guide if it helps understanding my problem: https://www.refersion.com/tracking

The doc specifies 2 ways to do it: by front end Javascript or thru a webhook. You have chosen the first. Furthermore, docs state:
" Within this code, you must dynamically insert the customer’s transaction information from the respective order. We’ve added some dummy order information for your reference. Not all data is required, but all is recommended. "

The only way to dynamically insert data in a Wix html-component is using postMessage/onMessage. I do not see any of this. If this is the case, please refer to thi Wix docs about the html-component.