# Prepopulating mautic form with variables from URL

**URL:** <https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [October 18, 2021, 3:33pm UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317 "2021-10-18T15:33:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![raramuridesign](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raramuridesign/32/13226_2.png) [@raramuridesign](https://forum.mautic.org/u/raramuridesign)\
**Post date:** [October 18, 2021, 3:33pm UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/1 "2021-10-18T15:33:15Z")

</div>

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](http://domain.com/contact?name=abcxyz)

And the above will populate the form.

Any assistance would be appreciated.  
M.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 19, 2021, 10:27am UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/2 "2021-10-19T10:27:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![raramuridesign](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raramuridesign/32/13226_2.png) [@raramuridesign](https://forum.mautic.org/u/raramuridesign)\
**Post date:** [October 19, 2021, 7:44pm UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/3 "2021-10-19T19:44:26Z")

</div>

@joeyk Thanks. main issue is that its not working 😉  
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

---

<div class="post-metadata">

**Author:** ![adiux](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/adiux/32/5793_2.png) [@adiux](https://forum.mautic.org/u/adiux)\
**Post date:** [October 20, 2021, 6:48am UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/4 "2021-10-20T06:48:55Z")

</div>

@raramuridesign you are aware of this?

> **[Managing forms | Mautic](https://docs.mautic.org/en/components/forms/managing-forms?&_ga=2.261790990.2013470482.1634711414-1285334467.1631117015#pre-populate-a-form-field-value)**
>
> . The new form view lets you create a form and attach any fields you want to collect from your users. After you've created the fields you can then define what actions you want to perform after the user submits the information.Form Overview. The form...

And there is also another discussion going on here:

> [@How to pass URL parameters to a form](https://forum.mautic.org/t/how-to-pass-url-parameters-to-a-form/15315/17):
>
> Merged a bunch of threads into this one - a documentation update is in the works to make this clearer!

Did you try testing in incognito mode?

---

<div class="post-metadata">

**Author:** ![raramuridesign](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raramuridesign/32/13226_2.png) [@raramuridesign](https://forum.mautic.org/u/raramuridesign)\
**Post date:** [November 11, 2021, 12:38pm UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/5 "2021-11-11T12:38:23Z")

</div>

@adiux @silavapi  
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.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [November 29, 2021, 3:26pm UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/6 "2021-11-29T15:26:50Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/7/70775a9d14dbef97954c4c6206ec4b13a935514d.png)

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

---

<div class="post-metadata">

**Author:** ![raramuridesign](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/raramuridesign/32/13226_2.png) [@raramuridesign](https://forum.mautic.org/u/raramuridesign)\
**Post date:** [November 30, 2021, 8:17am UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/7 "2021-11-30T08:17:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![2io](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/2io/32/7383_2.png) [@2io](https://forum.mautic.org/u/2io)\
**Post date:** [May 16, 2022, 7:04pm UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/8 "2022-05-16T19:04:53Z")

</div>

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](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](https://stackoverflow.com/a/14070223))

```auto
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](https://forum.mautic.org/t/link-for-leads-to-update-their-profile/5304/5) .

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

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [May 17, 2022, 8:59am UTC](https://forum.mautic.org/t/prepopulating-mautic-form-with-variables-from-url/21317/9 "2022-05-17T08:59:40Z")

</div>

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.

> **[Mautic Help Desk Meetup - May 17, 2022, Tue, May 17, 2022, 12:00 PM | Meetup](https://www.meetup.com/mautic-helpdesk-meetup/events/284361651/)**
>
> Tue, May 17, 12:00 PM EDT: Global and online-only! This free monthly meetup is for anyone who needs help in getting their Mautic questions answered and bringing their skills to the next level. Come a

Joey
