AssociateLead function help | Community
Skip to main content
Devin_Poehlman
Level 2
June 26, 2019
Solved

AssociateLead function help

  • June 26, 2019
  • 2 replies
  • 3997 views

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.  

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

"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? 


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.

2 replies

SanfordWhiteman
Level 10
June 26, 2019

Please highlight your code using the Advanced Editor's syntax highlighter so it's readable, then we'll continue.

Devin_Poehlman
Level 2
June 26, 2019

Done.

SanfordWhiteman
Level 10
June 26, 2019

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.

SanfordWhiteman
Level 10
June 26, 2019

(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.)

Devin_Poehlman
Level 2
June 26, 2019

Let's assume for this exercise I couldn't do that.