This feature uses VBScript/IF-THEN statements. Having a working knowledge of this will aid you more, but this document will still provide the tools needed to use Conditional Logic.
What is Conditional Logic?
Conditional Logic allows you to customize your emails in a more detailed manner than just Personalization. With Conditional Logic, you can easily create one email messages with several different options of content to be displayed to your recipients, based on the data stored for that recipient in your list.
An example of this would be creating one email message for all customers, but using Conditional Logic to send the message in different languages to each customer, based on their language spoken.
How to use Conditional Logic
To use Conditional Logic, you will use the popular Microsoft VBScript language. In JangoMail, VBScript statements must begin with [** and end with **].
For example purposes, lets say we are going to send out an email message to all of our customers wishing them a Happy Birthday with us. In our list of customers, we will have the following fields of data.
We will use the Conditional Logic functionality to insert "conditions" within the Body of the email message to display different content to different recipients, based on the language we have specified for each recipient.
In the email we would build out in 3 different content sentences, in 3 different languages: English, Spanish, and French. Conditional Logic general formatting is [** IF FieldName = "Value" Then **]. Once the content is built out, you will end with [** END IF **].
In our example of Conditional Logic statements we will be using the field name of: Language.
[** IF Language = "English" Then **]
We want to wish you a Happy Birthday with us! We value you as a customer and look forward to another year together!
[** ElseIF Language = "Spanish" Then **]
¡Queremos desearle un feliz cumpleaños con nosotros! ¡Lo valoramos como cliente y esperamos un año más juntos!
[** ElseIF Language = "French" Then **]
Nous voulons vous souhaiter un joyeux anniversaire avec nous! Nous vous apprécions en tant que client et attendons avec impatience une autre année ensemble!
[** END IF **]
- Use straight quotes rather than curly quotes. Use: "" NOT: ““.
This will work:
[** If Fieldname = "Value" Then **]
This will NOT work and will result in an error:
[** If Fieldname = “Value“ Then **]
- All fields in your list or your extracted data (if connecting to a database) are turned into variables at send time. Make sure your field names are legitimate VBScript field names. Field names should contain only alphanumeric characters (letters and numbers) and should NOT contain spaces. Also, field names CANNOT start with a number. For example, a field named "9Lives" would result in an error if using conditional logic statements.
- All variables are treated as strings unless you cast them to another type. For example, if you have a List with the following fields:
[** If CInt(Age) >= 21 Then **]
The same applies to variables containing dates as well. You can use the CDate function to convert the string literal to a variable of type date and you can use functions like DateAdd and DateDiff for advanced date manipulation.
- There may be cases where you wish to output a variable to your email message. In these cases you can use a special function called OutputString. For example, if you want to display today's date in your email, you can use:
[** OutputString(Date) **]
Frequently Asked Questions:
Q: What happens if I make a mistake in the syntax of my VBScript statements?
A: If your scripting results in an error, there will be an error displayed at the bottom of your screen. We will still allow you to attempt to send, however the campaign will result in an error, and will not actually send. We will show an error on the Message and Report page.
Q: What is the list of VBScript commands that can I use in my emails?
A: You can use almost all of the VBScript commands documented on Microsoft's website. The only functionality you can't use is the creation of ActiveX objects.
Q: How can I test my Conditional Logic code before sending out a mass email to my entire list?
A: You should set up a test list that has just enough recipients to simulate all of the "conditions" for which you have scripted your email message. You would save this list as a "Test" list, so you can use it in sending and when you use the "Send a Test" option.
Q: I am using the built in JangoMail HTML editor, and I noticed that the editor has put HTML tags within my blocks of script. Will this prevent my script code from rendering properly?
A: No, the script will still process properly. When the JangoMail script-processing engine goes to work, it removes any HTML tags that are in between the [** and **] delimiters.
Q: Is the JangoMail support staff available to help me implement scripts or debug a script that I wrote?
A: Yes, however, based on the extent of the assistance needed, this could come at a cost. This type of support is billed based on time needed by the JangoMail technician to assist you. For more information, please contact the JangoMail support team.
Please see Microsoft's VBScript Language Reference, for more on the VBScript language.
|Discover more of JangoMail's advanced features!|