Prepopulating mautic form with variables from URL

Hi All
I would like to know if there are any guides and or suggestions to prepopulate a mautic form which is embedded on a website.
I have seen numerous ways to do this, including php, javascript etc

I am looking for a solution which will do this
domain.com/contact?name=abcxyz

And the above will populate the form.

Any assistance would be appreciated.
M.

Exactly how it supposed to work.

You need to use the Custom field alias as GET value.
I tested and doesn’t work for me on 4.0.1, might be a bug or I’m using the wrong format.
J

@joeyk Thanks. main issue is that its not working :wink:
I was hoping we could add a variable to a url where the form resides and the data would be pre-filled. But this is not the case.
Any other suggestions?
M

@raramuridesign you are aware of this?

And there is also another discussion going on here:

Did you try testing in incognito mode?

@adiux @rcheesley
I think perhaps this was not explained correctly. Our requirement was to use a variable from the CMS we are using to populate into the form. we have used PHP code to do this, grabbing the variable from the URL.

I was hoping that these could be achieved by default onto the form form, but sadly not.
Anyway our approach works, as long as we do not use the JavaScript integration.

Hi,
Just tested, and it works in 4.0.1, I didn’t test correctly before my answer above.
You have to make sure, that this setting is on in your form field, that you want to pre-populate:

image

Once, this is selected, the form can be prepopulated by calling the page with
https://yourmautic.tld/landingpagealias?email=desiredemail@email.com

1 Like

@joeyk Thanks, will test and see what the outcome is. Never seen this setting before so good to know it is there.

Hello, I have V4.2.2 on VPS installed. I just tried prepopulating the email-field on the form that I added to this landing page: https://m.ionutojica.ro/actualizarea-numarului-de-telefon?email=test@test.com
It doesn´t seam to work. It should work, as you mention. Is it a bug in V4.2.2 ?
I am thinking to add this code to my page (https://stackoverflow.com/a/14070223)

var hashParams = window.location.hash.substr(1).split('&'); // substr(1) to remove the `#`
for(var i = 0; i < hashParams.length; i++){
    var p = hashParams[i].split('=');
    document.getElementById(p[0]).value = decodeURIComponent(p[1]);;
}

An older post (2017) I found, that mention the prepopulating the form-fields should work is this one: Link for leads to update their profile - #5 by Adam .

Do you have an idea, what am I missing?
I am not logged in, I use private session or other browser - the same happens.

Yes, the built-in Mautic prepopulation just works fine under 4.2.2.
Today we have a Mautic meetup, this will be one of the topics.

Joey

2 Likes