PUBLITRAC’s API JavaScript

1. Synchronize a lead (if the lead already exists, the lead will be updated) via PUBLITRAC’s JavaScript API.

Object Name: PubliPage.Api. SyncLead

Configuration: apiKey

Attributes: fields (contient les attributs du lead et leurs valeurs, voir la description complète des champs leads ici).

Custom Fields: fields.customFields (contient les champs personalisées et leurs valeurs)

Callbacks: OnSuccess, OnError

Methodology: post

Implementation example:  

<script type="text/javascript">

        $('document').ready(function()

        {

                $('#synclead').click(function()

                {

                        /* Form identification */

                        PubliPage.Api.SyncLead.config.apiKey = '87af7062-c756-11e0-9d7a-12313d018224';

                        /*Sync Lead Attributs */

                        PubliPage.Api.SyncLead.config.fields.token = '_nl-yourdomain.com-1323891914130-53205';

                        PubliPage.Api.SyncLead.config.fields.crmLeadId = 'CRM_ID134';

                        PubliPage.Api.SyncLead.config.fields.firstName = 'John';

                        PubliPage.Api.SyncLead.config.fields.lastName = 'Smith';

                        PubliPage.Api.SyncLead.config.fields.middleName = '';

                        PubliPage.Api.SyncLead.config.fields.company = 'ACME';

                        PubliPage.Api.SyncLead.config.fields.phone = '555-423-2453';

                        PubliPage.Api.SyncLead.config.fields.email = 'johnsmith@mydomain.com';

                        PubliPage.Api.SyncLead.config.fields.mailingAddress = '134 Ocean Street';

                        PubliPage.Api.SyncLead.config.fields.leadSource = 'New Production ABC';

                        PubliPage.Api.SyncLead.config.fields.originalSource = 'New Production ABC';

                        PubliPage.Api.SyncLead.config.fields.originalSourceType = 'Organic';

                        PubliPage.Api.SyncLead.config.fields.jobTitle = 'Software Engineer';

                        PubliPage.Api.SyncLead.config.fields.score ='10';

                        PubliPage.Api.SyncLead.config.fields.postalCode ='90211';

                        PubliPage.Api.SyncLead.config.fields.country ='USA';

                        PubliPage.Api.SyncLead.config.fields.city ='Compton';

                        PubliPage.Api.SyncLead.config.fields.state ='CA';

                        PubliPage.Api.SyncLead.config.fields.doNotCall = '0';

                        PubliPage.Api.SyncLead.config.fields.doNotCallReason = '';

                        PubliPage.Api.SyncLead.config.fields.unsubscribed = '0';

                        PubliPage.Api.SyncLead.config.fields.unsubscribeCause = '';

                        PubliPage.Api.SyncLead.config.fields.unsubscribeReason = '';

                        PubliPage.Api.SyncLead.config.fields.fax = '555-324-2134';

                        PubliPage.Api.SyncLead.config.fields.mobile = '555-432-1242';

                        PubliPage.Api.SyncLead.config.fields.isCustomer = '0';

                        PubliPage.Api.SyncLead.config.fields.isAnonymous = '0';

                        PubliPage.Api.SyncLead.config.fields.emailInvalid = '0';

                        PubliPage.Api.SyncLead.config.fields.emailInvalidCause = '0';

                        PubliPage.Api.SyncLead.config.fields.notes = 'This lead is very interest in product ABC';

                        PubliPage.Api.SyncLead.config.fields.suspended = '0';

                        PubliPage.Api.SyncLead.config.fields.suspendedReason = '';

                        PubliPage.Api.SyncLead.config.fields.blacklisted = '0';

                        PubliPage.Api.SyncLead.config.fields.blacklistedCause = '';

                        PubliPage.Api.SyncLead.config.fields.customerId = '';

                        PubliPage.Api.SyncLead.config.fields.website = 'http://www.acme.com';

                        PubliPage.Api.SyncLead.config.fields.language = 'fr';

                        PubliPage.Api.SyncLead.config.fields.nbrEmployees = '4';

                        PubliPage.Api.SyncLead.config.fields.revenue = '400000';

                        PubliPage.Api.SyncLead.config.fields.customFields = [{carColor : 'Red'},{carMaker:'Infiniti'},

                                                                             {carPackagesInterestedIn : [{name: 'Premium', desc: 'Lorem', price: '55000'},

                                                                                   {name: 'Best Value', desc: 'Lorem',price: '35000'}]}

                                                                            ];

 

                        /* Application callbacks (optionals) */

                        PubliPage.Api.SyncLead.onSuccess.callback = function(status,message)

                        {

                                if(console != undefined)

                                    console.log("Status:" + status + "\n" + "Message:" + message);

                        }

                        PubliPage.Api.SyncLead.onError.callback = function(message)

                        {

                            if(console != undefined)

                                console.log("Error:" + message);

 

                        }

                        /* End of application callbacks (optionals) */

                        /* Post the form */

                        PubliPage.Api.SyncLead.post();

                });

        });

    </script>

 

2. Add a lead to an empty list with PUBLITRAC’s JavaScript API

Object Name: PubliPage.Api.AddLeadsToList

Configuration: apiKey

Attributes: fields (contient les attributs du lead et leurs valeurs, voir la description complète des champs leads ici).

Custom fields: fields.customFields (contient les champs personalisées et leurs valeurs)

Callbacks: OnSuccess, OnError

Methodology: post

Implementation example : 

<script type="text/javascript">

        $('document').ready(function()

        {

                $('#addleadstolist').click(function()

                {

                        /* Form identification */

                        PubliPage.Api.AddLeadsToList.config.apiKey = '6221e616-180c-102e-9711-12313b072c51';

                        /* Add Lead To List attributes */

                        PubliPage.Api.AddLeadsToList.config.fields.name = 'The name of the list to add to';

                        PubliPage.Api.AddLeadsToList.config.fields.lead = [{email:'someone1@publitrac.com'},{email:'someone2@publitrac.com'}];

 

                        /* Application callbacks (optionals) */

                        PubliPage.Api.AddLeadsToList.onSuccess.callback = function(status,message) {

                                if(console != undefined)

                                {

                                    console.log("Status:" + status + "\n" + "Message:" + message);

                                }

                        }

                        PubliPage.Api.AddLeadsToList.onError.callback = function(message) {

                            if(console != undefined) {

                                console.log("Error:" + message);

                            }

                        }

                        /* End of application callbacks (optionals) */

                        /* Post the form */

                        PubliPage.Api.AddLeadsToList.post();

                });

        });

    </script>

 

3. Add a submitted form to an existing lead with PUBLITRAC’s JavaScript API.

Object Name: PubliPage.Api.AddFillOutFormHistory

Configuration: apiKey, email

Attributes: fields (contient les attributs du lead et leurs valeurs, voir la description complète des champs leads ici).

Custom fields: fields.customFields (contient les champs personalisées et leurs valeurs)

Callbacks: OnSuccess, OnError

Methodology: post

Implementation Example: 

<script type="text/javascript">

        $('document').ready(function()

        {

                $('#addfilloutformhistory').click(function()

                {

                        /* Form identification */

                        PubliPage.Api.AddFillOutFormHistory.config.apiKey = '6221e616-180c-102e-9711-12313b072c51';

                        PubliPage.Api.AddFillOutFormHistory.config.email = 'someone@publipage.com';

                        /* Add Fill Out Form History attributes */

 

                        PubliPage.Api.AddFillOutFormHistory.config.fields.information = 'Registration Form';

                        PubliPage.Api.AddFillOutFormHistory.config.fields.context = '';

                        PubliPage.Api.AddFillOutFormHistory.config.fields.formName = 'Infolettre';

                        PubliPage.Api.AddFillOutFormHistory.config.fields.url = '/infolettre.php';

                        PubliPage.Api.AddFillOutFormHistory.config.fields.values = 'Firstname: Claude <![CDATA[ Firstname: Claude Lastname: Sage Email: claude@sage.com Phone: 555-666-7777]]>';

                        PubliPage.Api.AddFillOutFormHistory.config.fields.sessionId = '2192c0f3802f8e0744e9940788121624';

 

                        /* Application callbacks (optionals) */

                        PubliPage.Api.AddFillOutFormHistory.onSuccess.callback = function(status,message) {

                                if(console != undefined)

                                {

                                    console.log("Status:" + status + "\n" + "Message:" + message);

                                }

                        }

                        PubliPage.Api.AddFillOutFormHistory.onError.callback = function(message) {

                            if(console != undefined) {

                                console.log("Error:" + message);

                            }

                        }

                        /* End of application callbacks (optionals) */

                        /* Post the form */

                        PubliPage.Api.AddFillOutFormHistory.post();

                });

        });

    </script>

4. Execute a campaign on a lead with PUBLITRAC’s JavaScript API.

Object Name: PubliPage.Api.ExecuteCampaigns

Configuration: apiKey

Attributes: fields (contient les attributs du lead et leurs valeurs, voir la description complète des champs leads ici).

Custom Fields: fields.customFields (contient les champs personalisées et leurs valeurs)

Callbacks: OnSuccess, OnError

Methodology: post

Implementation Example: 

<script type="text/javascript">

        $('document').ready(function()

        {

                $('#executecampaigns').click(function()

                {

                        /* Form identification */

                        PubliPage.Api.ExecuteCampaigns.config.apiKey = '6221e616-180c-102e-9711-12313b072c51';

                        /* Execute Campaigns attributes */

                        PubliPage.Api.ExecuteCampaigns.config.fields.leads = [

                                             {lead:[{email:'johnsmith@acme.com'}]},

                                             {lead:[{email:'johnsmith@acme.com'}]}];

                        PubliPage.Api.ExecuteCampaigns.config.fields.campaigns = [

                                             {campaign:[{name:'Trade Show May'}]}];

 

                        /* Application callbacks (optionals) */

                        PubliPage.Api.ExecuteCampaigns.onSuccess.callback = function(status,message) {

                                if(console != undefined)

                                {

                                    console.log("Status:" + status + "\n" + "Message:" + message);

                                }

                        }

                        PubliPage.Api.ExecuteCampaigns.onError.callback = function(message) {

                            if(console != undefined) {

                                console.log("Error:" + message);

                            }

                        }

                        /* End of application callbacks (optionals) */

                        /* Post the form */

                        PubliPage.Api.ExecuteCampaigns.post();

                });

        });

    </script>

5. Execute an email marketing campaign on one/many leads using PUBLITRAC’s JavaScript API. 

Object Name: PubliPage.Api.AddEmailCampaign

Configuration: apiKey

Attributes: fields (contient les attributs du lead et leurs valeurs, voir la description complète des champs leads ici).

Custom Fields: fields.customFields (contient les champs personalisées et leurs valeurs)

Callbacks: OnSuccess, OnError

Methodology: post

Exemple d'implémentation: 

<script type="text/javascript">
$('document').ready(function()
{
       $('#addemailcampaign').click(function()
       {
               /* Form identification */
              PubliPage.Api.AddEmailCampaign.config.apiKey = '6221e616-180c-102e-9711-12313b072c51';

             /* Add Email Campaign attributes */

            PubliPage.Api.AddEmailCampaign.config.fields.information = [{name:'Promotion January 2014'}];
           PubliPage.Api.AddEmailCampaign.config.fields.email = [
           {
                  fromName:'PUBLITRAC',
                  fromEmail:'no-reply@publipage.com',
                 subject:'January Promotion',
                 message:[
                           {
                                  html:'<![CDATA[<html><body>Hello <strong>{{FirstName;Default=}}</strong>.<br /><br />There is a new promotion this year…<br /><br /><br /></body></html>]]>',
                           text:'<![CDATA[Hello {{FirstName;Default=}}.There is a new promotion this year…]]>'
                      }],
                      options:[{sendAsSalesRep:false}]
                      }];

                     PubliPage.Api.AddEmailCampaign.config.fields.leads = [
                   {
                        lead:[
                              {
                                     firstName:'John',lastName:'Carmack',company:'ID Software',phone:'555-423-2453',email:'jsmith@acme.com',leadSource:'New Production ABC',originalSource:'New Production ABC',
                                    originalSourceType:'Web',
                                   customFields:[{GamePreferences:'Action',GamePlayed:'121'}]
                                    },{
                                    firstName:'John',lastName:'Smith',company:'ACME',phone:'555-423-2453',email:'jcarmack@idsoftware.ca',leadSource:'New Production ABC',originalSource:'New Production ABC',
                                   originalSourceType:'Web',
                                  customFields:[{GamePreferences:'Strategy',GamePlayed:'23'}]

                                   }
                                     ]}];

                       /* Application callbacks (optionals) */
                      PubliPage.Api.AddEmailCampaign.onSuccess.callback = function(status,message) {
                      if(console != undefined)
                      {
                              console.log("Status:" + status + "\n" + "Message:" + message);
                      }
              }
                PubliPage.Api.AddEmailCampaign.onError.callback = function(message) {
                if(console != undefined) {
                          console.log("Error:" + message);
                 }
              }
             /* End of application callbacks (optionals) */

            /* Post the form */
                PubliPage.Api.AddEmailCampaign.post();
             });
                  });
         </script>