Nope.. it was just the first example I could find 🙂
It doesn’t seem to have gone through any testing at all. The RegExp is bonkers.
FYR: This post on the nation also describes the concept of storing the UTMs in to a cookie and referencing it to add UTM values to the form's hidden UTM fields when the user fills out the form w/o UTMs.
Nice spot @Darshil_Shah1.
I don't think the part to populate the fields into the form is needed any more right, as Marketo can do that natively now.
You mean adding autofill on the hidden fields using the cookie value, right?
Correct
Would there be any race condition between the hidden form fields getting populated from the cookie by the form auto-fill and cookie being set/updated by the script? Wouldn't possibly wanna risk the possibility of hidden form values getting populated with the existing cookie values before the cookie can get updated with the new values from the UTMs. The script has a defined order of operations - first create/update the cookies from the UTMs if present, and then plug them in the hidden form fields.
Would there be any race condition between the hidden form fields getting populated from the cookie by the form auto-fill and cookie being set/updated by the script? Wouldn't possibly wanna risk the possibility of hidden form values getting populated with the existing cookie values before the cookie can get updated with the new values from the UTMs. The script has a defined order of operations - first create/update the cookies from the UTMs if present, and then plug them in the hidden form fields.
There’s no race condition if the code that manages the cookies runs before loadForm().
yeah - spot on!