Follow

Introduction to custom scripts

 

What is it?

When configuring the acceptance criteria for a campaign, one of the options is "Custom Script." This gives you the ability to use javascript to create your own advanced lead validation rules. It allows for validation that is interdependent between fields. It also gives you the ability to alter the actual lead data.

How do I configure it?

You must be the campaign owner to use it. A custom script can be set up on each campaign. From the campaign page, access the script editor by clicking the "edit custom script" link.

The syntax of the code you enter there is standard JavaScript, and is evaluated for each valid lead when it arrives in LeadConduit Classic in that campaign. Note that other acceptance criteria, as set on the campaign's fields, will have already run. The script will not be executed for invalid leads.

The script has access to all the field values of incoming leads; Click the question-mark icon or type "ctrl-." (ctrl-period) to see a pop-up reference of how to access those values. They can thus be evaluated in any way necessary. You also have access to the core extensions provided by the Prototype JavaScript framework, with the exception of browser related features.

Invalidating lead data

If a lead should need to be invalidated by the script, the script can invoke the function "lead.invalidate()", which takes a single string parameter: the reject reason.

In this example, the campaign includes a field called "program_of_interest" and another called "education_level". This script will invalidate the lead if program_of_interest is "EMS" but education_level is not one those listed:

Altering the lead data

If you use the custom script to alter lead data, the data will be stored in your LeadConduit account in its altered state. In addition, if the lead was submitted from a Seller Account, the account that provided the lead will also see it in its altered state. Invalid leads will not be altered.

The following script sets the program_of_interest field to "Nursing Degree" and strips punctuation characters out of the city field.

Notice that the same variables are not available to the custom script that are available in the delivery destination settings. You can see all the available variables without leaving the javascript editor just by clicking the small blue question mark icon in the upper right hand corner.

When does it run?

The custom script runs after the lead passes the initial validation that has been configured for the campaign (based on each of the individual fields). It also runs after duplicate checking. In other words, it only runs on leads that would be considered valid if there was no custom script.

Handling String fields

In order to allow string functions, such as length, to work on your lead fields, your script should explicitly cast those fields as strings. This also prevents errors that occur when handling missing fields.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

You must be logged in to comment.