LEADQ SDK





powered by marketing intelligence
LeadQ Tracker SDK  
Sample Form  
Field definitions  
Code Samples  
Docs  
CURRENT USER
not logged on
  LeadQ Tracker SDK .NET code samples  

C# Auto form post

Usefull code for a javascript pre-validated form. Posts all known request params at once.

//Load the LeadQ tracker SDK with endpointUrl and failoverURL
            LeadQSDK leadQSDK = new LeadQSDK(
                        "https://tracker.leadq.nl/Endpoint.asmx",  //EnppointURL
                        "https://tracker2.leadq.nl/Endpoint.asmx"//Failover URL
                        this);
            //set the proper ID's
            leadQSDK.session.campaignId =
                     new Guid("29CCE4D4-42DF-4993-870B-51CD6F431626");
            leadQSDK.session.formId =
                     new Guid("2C3D60E1-9809-4C20-8AA4-744D3EB5571C");

            //fill lead with formData
            leadQSDK.loadForm();

            //drop in callcenter
            leadQSDK.flowItem.flowId =
                     new Guid("A9705BC5-9E15-4503-8C9C-F67EBCD2537B");
            leadQSDK.setPrefferedCallMoment(LeadQSDK.DayPart.Evening);
            leadQSDK.postLead();

            //Display result
            lblPostMessage.Text = leadQSDK.lead.postMessage;
            lblPostState.Text = leadQSDK.lead.postState.ToString();
            lblSupplierPixel.Text = leadQSDK.lead.supplierString;
 

C# Manual post

Most common usage for implementing in existing webforms.

Lead lead = new Lead();

lead.leadLastName = "Doe";
lead.leadFirstName = "John";
lead.leadGender = 'M';
lead.leadBirthDate = new DateTime(19750722);
lead.leadEmail = "john@doe.com";

/* Leadhelper is a wrapper for the lead object providing
 * methods to ease up leadposting,
 * like the setPrefferedCallMoment
 */
LeadHelper helper = new LeadHelper(lead);

lead.leadPhonePrivate = "030 3138 647";
lead.leadPhoneWork = "030 3138 647";

//set the proper ID's
lead.campaignId =
    new Guid("29CCE4D4-42DF-4993-870B-51CD6F431626");
lead.formId =
    new Guid("2C3D60E1-9809-4C20-8AA4-744D3EB5571C");

//set sessioninfo:
lead.sessionClientIP = "127.0.0.1";

//drop in callcenter
lead.flowItem.flowId =
    new Guid("A9705BC5-9E15-4503-8C9C-F67EBCD2537B");

helper.setPrefferedCallMoment(LeadQSDK.DayPart.Evening);

//Load the LeadQ tracker SDK with endpointUrl and failoverURL
LeadQSDK leadQSDK = new LeadQSDK(
        "https://tracker.leadq.nl/Endpoint.asmx",
        "https://tracker2.leadq.nl/Endpoint.asmx"
);

//post the lead
leadQSDK.postLead();

Classic ASP

Because of the lack of SOAP capabilities on classic scripting languages like ASP, a simple HTTP-POST FORM is provided, without the use of a LeadQ Tracker SDK. LeadQ disencourages the use of classic scription languages!

strPostData=""

strPostData=strPostData & "&formId=" & formId
strPostData=strPostData & "&campaignId=" & leadQCampaignId
strPostData=strPostData & "&sessionStep=1"

strPostData=strPostData & "&leadLastName=" & Server.URLEncode(achternaam)
strPostData=strPostData & "&leadFirstName=" & Server.URLEncode(voorletter)
strPostData=strPostData & "&leadPrefixes=" & Server.URLEncode(voorvoegsels)
strPostData=strPostData & "&leadStreet=" & Server.URLEncode(straat)
strPostData=strPostData & "&leadHouseNo=" & Server.URLEncode(huisnummer)
strPostData=strPostData & "&leadZipcode=" & Server.URLEncode(postcode)
strPostData=strPostData & "&leadCity=" & Server.URLEncode(plaats )
strPostData=strPostData & "&leadPhoneWork=" & Server.URLEncode(teldag)
strPostData=strPostData & "&leadPhonePrivate=" & Server.URLEncode(telavond)
strPostData=strPostData & "&leadEmail=" & Server.URLEncode(email)
strPostData=strPostData & "&leadBirthDate=" & Server.URLEncode(geboortedatum)
strPostData=strPostData & "&leadGender=" & Server.URLEncode(strGender)
strPostData=strPostData & "&leadMemo=" & Server.URLEncode(opmerking)
strPostData=strPostData & "&flowId=" & flowId

Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST""https://tracker2.leadq.nl/web/pages/PostPage.aspx", False
xmlhttp.setRequesth3 "Content-Type""application/x-www-form-urlencoded"
xmlhttp.Send(strPostData)
'response.write xmlHttp.responseText 'optional code for displaying supplierpixel


Java

This codesample shows a part of a jsp-page that handles the doPost or the doGet method
Every time the method is called, the formStep in incemented and stored in the session

private void HandleRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {

                //formstep handling:
                int formStep=-1;
                if (request.getSession().getAttribute("formStep")!=null)
                        formStep = ((Integer)request.getSession()
                                        .getAttribute("formStep")).intValue();
                //increment the formstep each this method is called
                formStep++;
                request.getSession().setAttribute("formStep"new Integer(formStep));

                //Please use constructor with the "request" parameter, as shown below.
                //this enables the ability to repost the same lead with updated data
                LeadQSDK leadQSDK =
                        new LeadQSDK("https://tracker2.leadq.nl/endpoint.asmx", request);

                //replace this ID!
                leadQSDK.getSession().setCampaignId("29cce4d4-42df-4993-870b-51cd6f431626");

                //put your formId here
        leadQSDK.getSession().setFormId("2c3d60e1-9809-4c20-8aa4-744d3eb5571c");

        //gets a default prefilled lead
        Lead lead = leadQSDK.getLead();

        //Helperclass is userfull for setting the date through calendar
        //object instead of XMLGregoriancalendar
        LeadHelper helper= new LeadHelper(lead);

        //set lead properties
        lead.setLeadFirstName("John");
        lead.setLeadLastName("Doe");
        lead.setLeadGender('M');
        lead.setLeadEmail("john@doe.com");
        lead.setLeadStreet("mainstreet");
        lead.setLeadHouseNo("12");
        lead.setLeadHouseNoAdd("a");
        lead.setLeadZipcode("1234BA");
        lead.setLeadCity("New York");
        lead.setLeadPhonePrivate("1234567890");
        helper.setLeadBirthDate(Calendar.getInstance());
        lead.setLeadMemo("Extra information");
        lead.setFormStep(formStep);//stap 1

        //post the lead
                leadQSDK.postLead();

                //sets the result returned from the SaveLead()
                //function in session with name 'Result'
                request.setAttribute("Result", leadQSDK.getLead().getPostMessage());
                getServletConfig().getServletContext()
                .getRequestDispatcher("/GetLead.jsp").forward(request,response);

        }
 

PHP

Manual Post Example of a lead in PHP

<?php
require_once("service_setting.php");
require_once("../src/LeadQSDK.class.php");
// instantiate an instance of the LeadQSDK class
$LeadQSDK = new LeadQSDK();
// Instatiated a new session on first visit of the page.
$SessionObj = new Session();
// Fill the session
// Obliged fields
$SessionObj->campaignId = new Guid("29cce4d4-42df-4993-870b-51cd6f431626");
$SessionObj->formId = new Guid("2c3d60e1-9809-4c20-8aa4-744d3eb5571c");
$SessionObj->formStep =1;
// Optional fields
$SessionObj->sessionSearchTerms;
$SessionObj->sessionInternalRef;
$SessionObj->sessionUserAgent = "test agent";
$SessionObj->sessionSDKversion=21;
$SessionObj->postState=0;
$SessionObj->postMessage="";
$SessionObj->supplierString;
// Post the session
$result = $LeadQSDK->PostSession($SessionObj);
// Show debug information
//print('<pre>');
//print_r($result);
//print('</pre>');
// If status == 1, the post was unsuccesfull
if($result['Status'] != 1){
//debug
print("error posting session!");
exit();
}
// instantiate an instance of the Lead class, with an Session object as argument which is an super class of Lead, this is the Session returned by the webservice!
$LeadObj = new Lead($result['ReturnedObject']);
// Create an flowitem class
$LeadObj->flowItem = new FlowItem();
// Fill the flowitem class (all optional)
$LeadObj->flowItem->flowId = new Guid("A9705BC5-9E15-4503-8C9C-F67EBCD2537B"); //identifies the follow-up callcenter flow
//Lead properties:
// Fill the lead properties
$LeadObj->leadFirstName = "Jan";
$LeadObj->leadLastName = "Doe";
$LeadObj->leadPrefixes = "vander";
$LeadObj->leadInternalRef = "1asdas2";//own identifier if needed
$LeadObj->leadBirthDate = new DateTime();
$LeadObj->leadBirthDate->setDate(1983,04,18);
$LeadObj->leadGender = "F";
$LeadObj->leadStreet = "Mainstreet";
$LeadObj->leadHouseNo = "12";
$LeadObj->leadHouseNoAdd = "a";
$LeadObj->leadZipcode = "1234AB";
$LeadObj->leadCity = "New York";
$LeadObj->leadProvence = "Alabama";
//Phone properties:
$LeadObj->leadPhoneWork = "1234567890";
$LeadObj->leadPhonePrivate = "1234567890";
//Mail properties:
$LeadObj->leadEmail = "john@doe.com";
$LeadObj->leadKeepInformed = "1";
//Special properties:
$LeadObj->leadMemo = "John likes his coffee black";
$LeadObj->leadAmount = "12.01";
$LeadObj->leadXMLColumns = "a;b;c";
$LeadObj->leadXMLData = "<xmlRoot><coffee type=\"DE\">black</coffee></xmlRoot>";
// pass the LeadObj and calling the PostLead function
$result = $LeadQSDK->PostLead($LeadObj);
//print('<pre>');
//print_r($result);
//print('</pre>');
if($result['Status'] != 1){
//debug
print("error posting lead!");
exit();
}
?>


  LeadQ version 2.1