SOLVED

AssociateLead function help

Go to solution
Devin_Poehlman
Level 1

AssociateLead function help

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.  

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: AssociateLead function help

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.

View solution in original post

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: AssociateLead function help

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

Devin_Poehlman
Level 1

Re: AssociateLead function help

Done.

SanfordWhiteman
Level 10 - Community Moderator

Re: AssociateLead function help

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.

Devin_Poehlman
Level 1

Re: AssociateLead function help

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

SanfordWhiteman
Level 10 - Community Moderator

Re: AssociateLead function help

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.

View solution in original post

Devin_Poehlman
Level 1

Re: AssociateLead function help

Ah! that comma.  That was the issue.  

SanfordWhiteman
Level 10 - Community Moderator

Re: AssociateLead function help

Cool, please mark my answer as Correct, thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: AssociateLead function help

(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 1

Re: AssociateLead function help

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