Embed SalsaScript in an email blast

Conditional Content

*****For performance reasons you can not call other salsaScript objects. You can only get information from the supporter.getObjects method call.

Conditional content is a powerful addition to the email blast functionality of our Salsa platform. Conditional content refers to the ability to send an email blast with varying content based on certain criteria. For example, you want supporters that belong to group A to recieve content that is different from supporters that belong to group B. You might want to send an email that summarizes a supporters' donation history and ask them to make a new donation. You might want supporters that live in one state to get special text, while others receive something different.

By embedding salsaScript in your content, you can send varying content, specific to each supporter that meets a criteria. The main salsaScript object that will return a supporters' information is supporter.getObjects('objectyouwant') call. Based on the parameter called, an array of the supporters' information will be returned. All you then have to do is iterate through the result set to get the information that you want.

The best way to get acquainted with conditional content is to see some sample code.

  1. Group based
  2. You want supporters from groups_KEY 123 to receive one email and all other supporters to get another email

    Dear [[First_Name]] [[Last_Name]],
    
    Tomorrow, we embark on a new road....
    
    As a supporter that has ...
    <? 
      var groupList=supporter.getObjects('groups')	
      var groups = new Object();
      for each (g in groupList){
          groups[g.groups_KEY]=true;
      }
      if (groups['123']!=null) {
          ?>been active in street canvassing<?  
      }else{	
          ?>supported the organization by manning telephone banks...<?
      }
    
    ?>
    
    

    Thank you in advance for being a very important part of .....

  3. Donation based
  4. Analyze past donations

    Regular donations

    <?
      var donations=supporter.getObjects("donation");
      var count = 0;
      var sum = 0;
      var max = 0;
      var min = 0;
      for each(donation in donations) {
           //get sum
           sum+=parseFloat(donation.amount);
    
           //get max and min
           if (count==0) min = donation.amount;
           if (parseInt(donation.amount)>max) max=donation.amount;
           if (parseInt(donation.amount)<min) min=donation.amount;
           count++;
           ?>Donations thus far: donation KEY #<?=donation.donation_KEY?> in the amount
               of $<?=donation.amount?>
    <? } ?> Your total donations thus far are: <?=sum?> Your average donations thus far are: <?=sum/count?> Your maximum donation thus far is: <?=max?> Your minimum donation thus far is: <?=min?> <? if (sum>100 && sum<250) { ?>Please condsider making a donation of $25.00<? } else if (sum>=250 && sum<500) { ?>Please condsider making a donation of $50.00<? } else if (sum>=500 && sum<1000) { ?>Please condsider making a donation of $100.00<? } else if (sum>=1000) { ?>Please condsider making a donation of $500.00<? } else { ?>Please condsider making a donation of $10.00<? } ?> to help with keeping up the fight for....

    Recurring donations

    <?
    var recurring_donations = supporter.getObjects("recurring_donation");
    if (recurring_donations!=null) {
      for each (re in recurring_donations) {
        if (re.RESULT=='-1' || re.RESULT=='0') { 
         ?><b><?=re.PAYPERIOD?></b> <i>Start Date <?=re.Start_Date?></i> $<?=re.amount?>  
           <p>Please consider increasing your recurring donation by 
               <?=parseInt(re.amount)+10?> to help us meet our goals</p>
           <hr><?
        }
      }
    }
    ?>
    
    
  5. Action based
  6. <? 
    var sc = supporter.getObjects("supporter_campaign"); 
    if (sc!=null) { 
     for each (action in sc) { 
          ?><p><?=action.Letter_Subject?></p><? 
     } 
    } 
     
    ?>
    
  7. State based
  8. <?
    var supporterInfo=supporter.getObjects("supporter");
    for each (s in supporterInfo) {
      if (s.State=='VA') {
         ?>Viginia state supporters ...<?
      } else if (s.State=='DC') {
         ?>DC residents should...<?
      } else {
         ?>we don't have state information for you please update your profile<?
      }
    
    }
    ?>
    
  9. Zip code based
  10. <?
    var supporterInfo=supporter.getObjects("supporter");
    for each (s in supporterInfo) {
      if (s.Zip=='22003') {
         ?>Viginia state supporters ...<?
      } else if (s.Zip=='20009') {
         ?>DC residents should...<?
      } else {
         ?>we don't have zip information for you please update your profile<?
      }
    
    }
    ?>
    
  11. Chapter based
  12. <?
    var supporterInfo=supporter.getObjects("supporter");
    for each (s in supporterInfo) {
      if (s.chapter_KEY=='21') {
         ?>The chapter ...<?
      } else if (s.chapter_KEY=='2') {
         ?>You chapter is hosting...<?
      } else {
         ?>please take part in our efforts to<?
      }
    }
    ?>