Blind form submit for Known Visitors on non-Marketo LP

Highlighted

Blind form submit for Known Visitors on non-Marketo LP

Background, we would like to submit a blind form containing JSON when someone uses a tool on our corporate website. We have the following scenario:

1. Need to deploy via Google Tag Manager

2. Do not have access to email address via JS

3. Tool requires registration and that associates a cookie in MKTO record

Can we leverage Known Visitor HTML via a hidden form and add another hidden field to capture the JSON payload? And only trigger form submit on successful submission of the tool?

Here is really rough code for the Known Visitor HTML...

Am I way off base?

{{form.Button:default=Auto-submit}}  
<script>
MktoForms2.whenReady(function(form){
var formEl = form.getFormElem()[0],
formEl.addHiddenFields({
"jsonPayload":"{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}",
});
submitEl = formEl.querySelector(".mktoButton");

submitEl.click();
});
</script> ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
3 REPLIES 3
Highlighted
Level 10 - Community Moderator

Re: Blind form submit for Known Visitors on non-Marketo LP

Well, your jsonPayload field needs to contain valid JSON, to start with -- those nested quotes won't work. You'd use standard JSON.stringify on the object.

And addHiddenFields is a method of the Marketo Forms 2.0 custom object form, not a method of the native DOM <form> element that's returned by form.getFormElem()[0].

(The DOM element is used to manage native styles, native events, and native attributes. You don't need that here.)

So more like:

form.addHiddenFields({
someStringFieldThatHoldsJSON : JSON.stringify(someComplexJSObject)
});‍‍‍‍‍‍

But this needs to be triggered based on another tool's successful processing, and you haven't shown how that tool signifies that it's finished (what custom event it fires) and how it can pass on its payload for further processing.

Highlighted

Re: Blind form submit for Known Visitors on non-Marketo LP

Thank you Sanford. 

The JSON validity and form element call outs were super helpful. 

But this needs to be triggered based on another tool's successful processing, and you haven't shown how that tool signifies that it's finished (what custom event it fires) and how it can pass on its payload for further processing.

Correct, when the other tool's processing completes, there is a current process to grab the JSON and push it to another system. We would use that event (though I'm not exactly sure what it is), which our web team has setup. 

The goal was to understand the Marketo piece and then pass the approach off to our web team to implement.

So the final piece, with the context above... Can we leverage Known Visitor HTML via a hidden form and a only trigger form submit on successful submission of the tool?

Highlighted
Level 10 - Community Moderator

Re: Blind form submit for Known Visitors on non-Marketo LP

So the final piece, with the context above... Can we leverage Known Visitor HTML via a hidden form and a only trigger form submit on successful submission of the tool?

Sure, but I'm not clear on why you want to submit for Known Visitors (already associated sessions) only. Do you not have a way of knowing the person's email address in JS? 

What is the timing you're looking for?  If some back end process does the session association, then the form will not pick up that there's a Known Visitor unless the form is only loaded afterward. The timing has to be precise.