Re: Javascript API - associateLead

Anonymous
Not applicable

Javascript API - associateLead

I'm stuck and could use some help.  I've gone through the documentation over and over to try to figure out how to implement the associateLead function.  One of the problems is trying to determine if the code is working properly.  Does any know of a way to do this?  Also, is the code structured properly?

The munchkin already sits on the page.  

The code I'm using is below.  I understand that the apikey should be done on the server and it will.  For now I'm just trying to get this to work.  I know all the variables are loading correctly.  I also know that the hash is being created.  It's the rest of the call I'm not sure about....

<script type="text/javascript">
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script>
    MarketoUpdate();
    function MarketoUpdate() {
        var email = "[user:email]".toLowerCase();
        var FirstName = "[user:FirstName]";
        var LastName = "[user:LastName]";
        var key = "myapikey";
        var hash = CryptoJS.SHA1(key.concat(email));
        mktoMunchkinFunction('associateLead', {
            Email: 'email',
            FirstName: 'FirstName',
            LastName: 'LastName'
        }, 'hash');
    }
</script>

Tags (1)
5 REPLIES 5
Kenny_Elkington
Marketo Employee

Re: Javascript API - associateLead

Hey Steve,

What does your GET end up looking like?  Could you also provide an example email and key that you use to generate the hash to compare with?
Anonymous
Not applicable

Re: Javascript API - associateLead

Hey Kenny...

Not sure what you mean by what my GET looks like.??
Kenny_Elkington
Marketo Employee

Re: Javascript API - associateLead

Hey Steve,

The associateLead function generates a GET http request to your Marketo instance when it runs.  Can you capture this request and post it?
Anonymous
Not applicable

Re: Javascript API - associateLead

I could if you could explain how to capture it or point me to an article on how to do that.
Anonymous
Not applicable

Re: Javascript API - associateLead

Kenny...

Here is the GET and I NOW HAVE this working properly.

GET /webevents/associateLead?_mchNc=1386318971968&_mchKy=560fc82a2f9f87315e768e5eb68c948bf42c30d3&_mchAtEmail=dude%40schooldude.com&_mchAtFirstName=School&_mchAtLastName=Dude&_mchId=583-IUG-201&_mchTk=_mch-schooldude.com-1385475605156-27199&_mchHo=www.schooldude.com&_mchPo=&_mchRu=%2F&_mchPc=http%3A&_mchVr=134 HTTP/1.1

Below is the code for those that are interested.  PLEASE note..that this was for testing purposes only.  You should not be using client side javascript to calculate the SHA-1 hash.


<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script>
<script src="http://munchkin.marketo.net/munchkin.js"type="text/javascript"></script>
<script type="text/javascript">
    var email = "[user:email]".toLowerCase();
    var key = "putyourkeyhere";
    var hash = CryptoJS.SHA1(key.concat(email));
    var sendhash = "" + hash;
    mktoMunchkin("XXX-XXX-XXX"); 
    mktoMunchkinFunction
        ('associateLead', {
            Email: '[user:email]',
            FirstName: '[user:FirstName]',
            LastName: '[user:LastName]'
        }, sendhash);
</script>