Capturing info from non Mautic forms

I am looking to push info from a non Mautic form to Mautic for tracking purposes and capturing conversions.

What is the easiest way to do this so that it captures the tracking cookie and merges with the already existing anonymous data?

This is how I do it.

Wow, that’s exactly what I’m trying to do. Thank you soooo much. Just need to figure it out with other forms but as long as it passes the info to url I should be good from what I understand.

I used this code as you indicated:

script>
var __fields = decodeURIComponent(location.search.toString().slice(1)).split(“&”)

__fields.forEach( param=> {
const [fieldName, fieldValue ] = param.split(“=”);
const el = document.querySelector(form *[name="mauticform[${fieldName}]"]);
if( !!el ) el.value = fieldValue;
})

It’s not passing the info to the mautic form, is there something I need to change in that code?

The fields are showing in the URL

<script>
var __fields = decodeURIComponent(location.search.toString().slice(1)).split("&")

__fields.forEach( param=> {
  const [fieldName, fieldValue ] = param.split("=");  
  const el = document.querySelector(`form *[name="mauticform[${fieldName}]"]`);
  if( !!el ) el.value = fieldValue;
})
</script>

Double check the code. The above is taken right from my site where it works daily.

If you copied the code from my blog, then I have had issues with the editor adding space to the code that don’t belong.

Got it thanks.

@leoschuler @robm is there a way to also capture the information using the following tracking pixel?

https://example.com/mtracking.gif?page_url=cart_screen&email=myemail@example.com

How would I putll the email value using this example?

not sure I understand what you trying to do, the link you have as an example is the mautic tracking gif, do you want to read the data from the page url and include it in the tracking gif, is that what you want?

Yes, thanks to Rob I can now capture this if I can embed a hidden form but times when I can’t can I capture form fields from the tracking gif?

you can create a script that loads the gif url with the same parameters of the page url you are visiting, you can also customize the track function

mt('send', 'pageview', {email: 'my@email.com', firstname: 'John'});

those solutions will involve insert a javascript into the page, which is the same requirement for adding a hidden form

more details of the tracking script here: Contact tracking | Mautic

My question, and maybe this is because I’m not developer, is what goes in the where it says email: ‘my@email.com’ I’m sure you need to put the Field HTML values or something there. Sorry for the newbie question