Hi There,
Im at the pointy end of a project that is due soon and something is amiss so any help is appreciated.
Here is what I am trying to achieve.
1. Customer receives email to complete a survey on survey monkey
2. After completion they are redirected to a landing page
3. There is a smart campaign listening for this to occur
4. Program status changed to > completed survey
I have been trying unsuccessfully for a day to sort this.
Thanks
Matt
Solved! Go to Solution.
You already had the redirection code (in the onSuccess). You seem to be cutting and pasting from different sources.
The full code to auto-submit and redirect is:
<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1057"></form>
<script>
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
location.href = "https://www.surveymonkey.com/r/5KQ3VGB";
// Return false to prevent the submission handler continuing with its own processing
return false;
});
form.submit();
});
</script>
You will need the Munchkin JS and Muchkin.init() as well. But, as I've noted, your resulting code will have a race condition. It will not satisfy your requirements reliably. I would not use it on a production site.
1/ You can set up the follow-up page when defining the form in Marketo, you do not need to do it in the JS.
Unless you're using the same form for multiple possible destinations, yes.
There's still a race condition here, btw. Unlikely as you are to encounter it, there is actually no contractual (in the programming sense) guarantee that the Munchkin cookie will exist at the time you submit the form.
Hi again Sanford,
Since the issue is when the munchkin code is executed, would it make sense to use a free form template without the default Marketo code and add to it the synchronous/simple munchkin followed by a small JS that sends the lead to the SM page when it's completed ?
-Greg
P.S. You are going to Summit next year, I hope? I feel there are so many late-night geek sessions waiting to happen...
Hi again Sanford,
I am not sure I'll have time. I am running a small shop during the day and it's really hard to be away almost a week (including travel time).
-Greg
Hi,
The value 999-xxx-999 is this referring to the munchkin code. Also The second part of the JS is this right for the re-direct?
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
location.href = "https://www.surveymonkey.com/r/5KQ3VGB";
// Return false to prevent the submission handler continuing with its own processing
return false;
});
});
</script>
I answered my own question. Its the Munchkin code.
I just need to figure out the redirect.
Here is the code
<script src="//app-ab02.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2190" style="display:none"></form>
<script>
MktoForms2.loadForm("//app-ab02.marketo.com", 663-HBN-994", 2190, function(form) {
MktoForms2.whenReady(function (form) {
form.submit();
});
});
</script>
You already had the redirection code (in the onSuccess). You seem to be cutting and pasting from different sources.
The full code to auto-submit and redirect is:
<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1057"></form>
<script>
MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
location.href = "https://www.surveymonkey.com/r/5KQ3VGB";
// Return false to prevent the submission handler continuing with its own processing
return false;
});
form.submit();
});
</script>
You will need the Munchkin JS and Muchkin.init() as well. But, as I've noted, your resulting code will have a race condition. It will not satisfy your requirements reliably. I would not use it on a production site.
Hi Sanford,
For some reason the page goes no wear, here is the full script
<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2190"></form>
<script>
MktoForms2.loadForm("//app-sjst.marketo.com", "663-HBN-994", 2190, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
location.href = "https://www.surveymonkey.com/r/5KQ3VGB";
// Return false to prevent the submission handler continuing with its own processing
return false;
});
form.submit();
});
</script>
If you look in your console, you'll see that form is nuil.
form is null because subscriber (Munchkin ID) "663-HBN-994" is not valid. You can see this in the response to getForm().
Hi Sanford, I know this must be like pulling teeth, but what do I put in the Muchkin id parameter within the js.
That's your Munchkin Account ID. You can see it under Admin >> Integration >> Munchkin.
Thats confusing as that is where I got the code from the start and is not working
Hi Matthew,
Please paste the URL of the Landing Page.
-Greg
Here is the munchkin code
And here is the form url
http://pages.nlc.com.au/2015-11-Customer-Survey_LP-Auto-redirect.html
Your code in the LP is :
<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_2190"></form>
<script>
MktoForms2.loadForm("//app-sjst.marketo.com", "663-HBN-994", 2190, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
// Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl
location.href = "https://www.surveymonkey.com/r/5KQ3VGB";
// Return false to prevent the submission handler continuing with its own processing
return false;
});
form.submit();
});
</script>
So it's likely the code 2190 for the form ID is not correct.
Please check this then (go to the form in Marketo, then "form action -> embed code".
-Greg
This is the embed code for the form, it appears ok?
Apparently, it works...
One of the lessons to be learnt is that to work on forms 2.0, always start from the code extracted from Marketo.
-Greg
Nice work on this I learned a lot!
You still have a app-sjst in a URL, line 337 of the page.
MktoForms2.loadForm("//app-sjst.marketo.com", "663-HBN-994", 2190, function(form) {
change it to
MktoForms2.loadForm("//app-ab02.marketo.com", "663-HBN-994", 2190, function(form) {
-Greg
Just Tried on a new LP, still no go
Defiantly. Maybe the Lp is bugged Ill try it on a new one