web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

EventListener on 'd365mkt-afterformload' not firing consistently after navigating away/back to form

(0) ShareShare
ReportReport
Posted on by
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.
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 117

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 117 Super User 2025 Season 2

#3
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 83

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans