Tracking Code or Rest API: How to create new users in mautic? How to get mautic contact id from tracking?


I’m new using mautic and have a question about how to generate new users in mautic.

My use case is a simple registration form on a website. And important: This is not a form from mautic!

When I include the tracking code mautic is the first instance that knows about the user (as visitor). So the user clicks on the page (what is already tracked by mautic), hits the registration form and registers on my site/in my backend.

After this I pass the user data like name and email to the mautic tracking code as custom parameters. This turns the visitor to a know contact in mautic.

I hope I get and explained the mautic-flow right so far.

I ask myself if its necessary to do also any rest call after registration, maybe kind of registration-event-listener which creates a contact in mautic via Rest API. But I think this is not needed because mautic already has created this contact.

One of my requirements is that I want to save the mautic contact id also in my data (for knowing if the user is already connected with mautic and to identify the contact in mautic).

So what is a good way to handle this if the contact was created with tracking code? In case of Rest-Call it would be clear - I think the rest response should contain the mautic contact id. But how can I get the contact id if there is rest call?

Hope you can understand my explanation and help me with this issue!

Best regards,


Hi, it is well documented here:

There are multiple ways how the tracking data can be added.
Also check this:

If you make rest calls, you can always use the email as unique identifier for getting the contact ID. See docs.

1 Like


thanks for your reply!

I have to re-ask to make it clear for me:

1.) When I use the tracking script with custom parameters for the user it is not necessary to create a contact in mautic via rest api because the contact is created by the tracking script. Right?

2.) To get the mautic contact I can make a rest call on the server side so I can get and save the mautic contact id in my data/backend. Right?
Or is there another way, maybe get the contact with mautic js api in client?

Thanks for some help with this!

Best regards,



  1. Correct, the js will check the cookie. If it’s available, then append info, if not, then create a new contact.

  2. Correct. Not sure exactly in what environment you want to do it, but you can do it.

You should check this Forum thread to be aware of the limitations:

Thanks for your reply and sorry for my late reponse.

Unfortunately I have to reask cause I’m very unsure with this:

Would you recommend to create a new contact with custom parameters in tracking script (like: mt(‘send’, ‘pageview’, {email: ‘’, firstname: ‘John’})) or is it better to make a rest call to create a new contact?

I’m really unsure what data I should send in custom parameters in tracking script. Nothing? Just a uuid or the email? Or even all relevant data mautic has to know about the contact?

What are best practices for this use case?

Hope you can help me with this!

Best regards,