Contact tracking: optional custom parameters and transfer of url in mt() event

Your software
My Mautic version is: 3.1.0

Your problem
I am currently using the standard script:


    mt('send', 'pageview');

I want to track every user login to the site (user parameters must be displayed in the tracking), as well as every step of registering a new user (entering email, entering name and surname, etc.).

As far as I understand, I have to add a function to the standard script (or instead of it), which I will call in different parts of my project (user login, first login step, second login step, etc.), in which there will be something like

function sendEvent(email, name, surname, address, ...) {
mt('send', 'pageview', {email, name, surname, address});

I can’t figure out how to write such a function, how it should interact with the standard script above (it also has mt() event) and how to make parameters optional (for example, when registration has only email)

I want get url ‘https://myurl/mtc.js’ from backend (appsettings.json). How can this be implemented? Is it possible to transfer the url to the mt() event as a parameter?

Hi, there is an article about this:

joeyk, thank you for your answer, I got the 1st part. The question with transferring U(url) parameter from main function to mt remains open.