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.
I still see "app-sjst" in the LP. Have you approved it after your change ?
-Greg
Updated doest seem to be firing
<script src="//app-ab02.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>
That matters a lot.
Yes it does, and all the codes are correct.
What is different in your JS and in the screen shots are the first lines:
The scr URL is not the same.
In your LP, it shows
<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
in the screen shot, it's :
<script src="//app-ab02.marketo.com/js/forms2/js/forms2.min.js"></script>
I a not sure it matters, but we should eliminate this, so please fix the LP.
-Greg
You need to use your Munchkin ID and an existing form ID in your instance. That's the only thing stopping that code from working. I'm not just speaking from memory -- I literally embedded that code in a webpage and it worked (or "worked" in quotes, given the other caveats).
Since the issue is when the munchkin code is executed, would it make sense to use a free form with a template without the default Marketo code that adds the synchronous munchkin followed by a small JS that sends the lead to the SM page when it's completed ?
Yes, it would.
This whole process really needs to be either synchronous or tightly-managed-async or it's going to screw up.
Hi Sanford,
Doesn't the "wenReady" method help on this ?
-Greg
Doesn't the "wenReady" method help on this ?
As you probably already figured, nope.
You've got two processes running both automatically and asychronously that usually have a human factor "guaranteeing" enough breathing room.
Hi Greg,
One last question I think, how can I set up the redirect to the SM page.
Thanks
Hi Matthew,
There are several ways to 'auto submit' a form.
Basically,
1> Create a Marketo simple form landing page(may be with only email address)
2> On this landing page, add javascript code like,
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
window.document.forms[0].submit();
});
</script>
Basically, as soon as this landing page is loaded in browser, that form gets auto submitted. Assuming that the email address was pre-populated, it will create a 'form filled' event in Marketo which you can listen to in your smart campaign.
3> Have this form redirect to your SurveyMonkey form.
Hope this helps
Rajesh
Hi Rajesh,
IMHO, better use Marketo forms 2.0 API to do this.
-Greg
I agree with you.
As I said, there are multiple ways to do it. The one I mentioned is a more generic way which anyone without Marketo expertise would be able to do.
Rajesh
That is not correct. When forms may be dynamically inserted into the DOM after domReady, you must use their own API. Otherwise you are creating a race condition. Please do not recommend this going forward.
I see. Thanks
Rajesh
Hi Matthew,
This will be easier if you use a free form LP. A white one will do the job. Create the form in Marketo. Do not add it to the LP in the standard way, and get form embedded code instead.
It will look like this :
<script src="//app-e.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1272"></form>
<script>MktoForms2.loadForm("//app-e.marketo.com", "999-XXX-999", 1272);</script>
Just change the middle line code to :
<form id="mktoForm_1272" style="display:none"></form>
and the last line to :
<script>MktoForms2.loadForm("//app-e.marketo.com", "999-XXX-999", 1272, function(form) {
MktoForms2.whenReady(function (form) {
form.submit();
});
});
</script>
Paste the result as an HTML block in the page.
More to be found here : Forms 2.0 » Marketo Developers
-Greg
Ive tried on 3 browsers firefox, chrome and edge
Its weird as its picking up a new subscriber.
Ive been at this for 15 hours, just saw my spelling mistake
Hi Matthew,
You probably need to start the tests from 0, with clean browsers.
If you have a Marketo LP just before entering the survey, just try something : add a couple of lead tokens ({{lead.id}}, {{lead.Email Address}}, {{lead.last name}} to the first page. Do the same with the last one. It will enable to check whether the lead is "recognized" by Marketo when you arrive from the email link.
If it's not, the problem comes from one of these possibilities :
If it does show the values, then it can come from the following :
-Greg
Im going to give it a rest for tonight, if anyone can see what Im doing wrong any help would be appreciated.
Thanks
Is it all possible that this is occurring because I edited and moved around the program steps in admin?
Thanks
No, surely not.
-Greg