4 Replies Latest reply on Aug 7, 2015 11:47 AM by 14de86e539c60d1c8ac92b432134d50ff1222043

    anonymous lead id

    Vu Ngo

      I would like to update a custom field on an anonymous lead object but I need the lead ID in order to do so. All I have access to is the Munchkin cookie value and I can not find the API call that would return the lead ID for the anonymous lead object. Again, I only have access to the cookie value so I am using the cookie value as the filterType/filterValue. Is this even possible?


      Here is the API call to get the lead ID using the Munchkin cookie value:


      This API call returns the lead object just fine with known leads.

        • Re: anonymous lead id
          Sanford Whiteman

          This is a known omission from the REST API. You can do it using the SOAP API (I forget the name of the corresponding method, but you should find it easily in the docs).


          What data are you adding to the anonymous lead, though? Are you sure you want to only let the first 10,000 visitors each day get this data?  How is it actionable? Perhaps there is another, more scalable way to augment the lead data.

          • Re: anonymous lead id

            Hi Vu,


            It seems Sanford has run into this problem, as have I.   This limitation lead to me using the SOAP API's 'getLead' function using the 'COOKIE' identifier.


            Here's a test SOAP API script using the PHP helper library that grabs the MKTO Lead Id using the Cookie Id.   (the script will need some light edits before testing)


            [code example start]




            $user_id = MKTO_USER_ID;

            $encryption_key = MKTO_ENC_KEY;

            $soap_endpoint = MKTO_SOAP_ENDPOINT;


            //Connecting to Marketo

            $marketo_client = new mktSampleMktowsClient($user_id, $encryption_key, $soap_endpoint);

            if (empty($marketo_client)) echo "Error loading fpSDK!";


            //not sure on spec. this is a placeholder

            $mktoCookie = COOKIE VALUE HERE

            echo $mktoCookie;


            $checkLead = $marketo_client->getLead('COOKIE', $mktoCookie);


            /* debuggin

            echo 'checkLead:<pre>';


            echo'</pre><br /><br />';



            $leadRecord = $checkLead->result->leadRecordList->leadRecord;


            /* debuggin

            echo 'leadRecord:<pre>';


            echo'</pre><br /><br />';



            if ($checkLead == null) {

              // DO ERROR HANDLING HERE!

              echo 'Record Does Not Exist';


            } else {


            $leadId = $leadRecord->Id;






            [code example end]

              • Re: anonymous lead id
                Sanford Whiteman

                Nice.  But I do wonder what the situation is that requires data enhancement on anonymous leads, but only for the first 10,000 visitors per day.  I doubt the API should be used here.

                  • Re: anonymous lead id

                    Hi Sanford,


                    You have a great point that API limits play a big factor in this.  Like yourself, I would not suggest this technique for a homepage or high traffic asset. 


                    Another good question is why even do this?  To be honest, I had to look back at my notes on this project   


                    We had a 7 question 'ROI Calculator' asset and asked several questions before acquiring an email address. With our requirements for design, function and affiliate tracking, it was actually easiest to use the API rather than forms.


                    As each question is answered, we were updating anonymous MKTO records with a JSON string to store ROI results.


                    At the end of the quiz, there is a basic breakdown but the lead can opt-in to get a full analysis emailed to them.   The 'Full Analysis' is just a link to a page that breaks out the JSON string using a lead id in the url string. 


                    In short, we were front-loading data before an Email was captured (on a low-volume asset) and only had the API to work with for the use case.