Does anyone have experience working with D365 Customer Insights Journey 'Forms'? I'm struggling with updating a simple form field based on this event listener:
document.addEventListener('**d365mkt-afterformload**', function () {
console.log("[Visitor Tracking] D365 form loaded, injecting referrer...");
console.log("Field Inputted")
});
Basically, onload of the webpage my code captures the referral url via document.referrerbut the second half of my code is designed to ingest that referral info into a form field which is the problem. It works on load but not when a user navigates away and comes back to the form. It behaves inconsistent as sometimes it populates the field, and other other times it doesn't, sometimes the code fires sometimes it doesn't.
Note: This code is stored within Google Tag Manager and fires on all pages.
I am a Dynamics Developer not a web developer but do have some experience with html, css, js, react. Which is why I volunteered to pick this project which has been in back log for months and we are a very small team, just joined recently.
As we have over 30 forms on our website it would be time consuming to update HTML for all customer insights forms else this would work already.
Full Code in attachements:
Written in JS.