We have some landing pages on Unbounce that we need to keep on Unbounce but we want to connect those new leads with their anonymous web behavior. I'm trying to get the associatelead function to work but having trouble. I'm passing the form values in the URL to the thank you page. This is the code on the thank you page.
<script>
jQuery(window).on('load', function() {
Munchkin.munchkinFunction(
'associateLead',
{
FirstName: <?php echo 'decodeURIComponent("'. rawurlencode($_REQUEST["firstName"]) . '")'?>,
LastName: <?php echo 'decodeURIComponent("'. rawurlencode($_REQUEST["lastName"]) . '")'?>,
Email: <?php echo 'decodeURIComponent("'. rawurlencode($_REQUEST["email"]) . '")'?>
},
'<?php echo hash('sha1', '*[Your Marketo Secret]*' . $_REQUEST["email"]; ?>'
);
});
</script>
And this is how is it rendering on the page load:
<script>
jQuery(window).on('load', function() {
Munchkin.munchkinFunction(
'associateLead',
{
Email: decodeURIComponent("associate4%40test.com") FirstName: decodeURIComponent("Devin"),
LastName: decodeURIComponent("Poehlman"),
},
'564ee5a897297b0460926ea44af5e3312a4a800e'
);
});
</script>
What am I doing wrong? I double-checked the field names and secret key.
Solved! Go to Solution.
I'm saying your pasted output has a missing comma, which would throw a JS error.
Note this technique, even when seemingly working, has an inherent race condition and will cause duplicates. I suppose you can worry about that later.
Please highlight your code using the Advanced Editor's syntax highlighter so it's readable, then we'll continue.
Done.
Are you talking about the missing comma? Check to make sure you've deployed that PHP page w/the shown version.
Don't really understand why you're URL-encoding and then decoding in JS. You just need JS-safe encoding in one place.
"Done" refers to the request to highlight the code in Advanced Editor. I'm trying to leverage this code: https://community.unbounce.com/t/solution-marketo-unbounce/15613
Dismissing the encoding then decoding part. What am I missing here?
Ah! that comma. That was the issue.
Cool, please mark my answer as Correct, thanks!
(Also, there's no need to use the Munchkin API for this. Far easier is integrating the Unbounce Forms directly with Marketo -- not using UB's broken "integration" but processing the forms as standard Filled Out Form activities.)
Let's assume for this exercise I couldn't do that.