Skip to content

If then logic

edited April 2013 in Suggestions

Does Sendy have any kind of decision making logic? The sort of thing I'm thinking is as follows..

  • Good email lists allow subscribers to pick areas of content that interest them, in order to receive more appropriate emails and increase engagement
  • This could be handled by custom fields on the subscriber, e.g. [France], [UK], [Spain] on a holiday offers email (which would need a new "yes/no" field datatype I guess.
  • A single email template could then be sent to the whole list, but the content sent to each subscriber would be slightly different depending on their preferences. E.g. one person only gets the Spain section, while another gets the UK and France
  • Technically, this could be handled by more smart tags like , e.g. preference based content goes here
  • Potentially it would be nice to nest the decision making logic

Is anything like this possible already? Could it be added if not?

Martin

«1

Comments

  • Hi Martin,

    Is anything like this possible already?

    No, these are not available in Sendy yet.

    Could it be added if not?

    You can edit and/or write your own code if you wish to add these.

    Thanks.

    Ben

  • @ben, I'm not sure if I'm understanding exactly what @addactive is wanting here but the form we just did for Lou had a drop down allowing users to sign up for one or more areas of interest. Of course, this was handled at signup and it sounds like @addactive may be wanting backend logic integrated into the Sendy admin.

  • BenBen
    edited April 2013

    @vincentpolisi - Perhaps I have misunderstood @addactive's question.

    At first it sounds to me like a segmentation feature request (maybe it is as well), but reading it again sounds more like it could be done with custom fields.

    @addactive - if you want users to select their preferences when signing up from your subscription form, add custom fields to your list. These custom fields will appear in the Sendy provided subscribe form code. If you want more advanced ways for users to select options and then pass these data into your custom fields, you may want write your own subscription form code while integrating it with the API.

    When you send a campaign, you can use custom fields as personalization tags so each email appears slightly different or should I say, personalized for each user.

    Ben

  • @Ben,

    We're much less concerned about how people's interests are maintained than we are the ability to use logic to personalise the emails sent.

    Rather than just simple personalisation fields, I'm keen to personalise whole chunks of an email body based on their custom fields.

    Martin

  • I'm trying to do this when people sign up...but, I'm trying to capture people's selections with a select drop down...and I'm having trouble moving this data over to the fields - I have a 4 fields - name, email, zip code and custom options, but when people do multiple selections on the drop down, only one of the options maps to the custom options field. This may not be the right place to ask this question, but I'd greatly appreciate anyone's input/help!!!

  • Is there any further news on this @Ben?

    To explain in more detail, let's say I have an email about offers on new brands of cars. When people sign up, they can tick VW, Ford, Mercedes, BMW, etc.

    Then when I set up the campaign HTML/Plain Text, I can put a chunk of logic in, like this:

    [IF:BMW,True]
    Display all the BMW offers!
    [ENDIF]

    This would work really well for all sorts of uses. It's becoming critically important with email engagement to be able to customise what people receive according to their interests. At the moment, the matrix of possibilities just cannot be achieved with Sendy unfortunately.

  • I was able to modify the Sendy code to give some form of this functionality. Using the following code, you can add [Field,if-then=stuff goes here] to allow some html to only show when the customer has the custom field. It only works as a boolean (this field is not empty) but it is a start for future modifications. Please use it if it works for you.

    You'll need to edit four files:

    • /scheduled.php
    • /w.php
    • /includes/create/send-now.php
    • /includes/create/test-send.php

    In scheduled.php and send-now.php files, look for the line of code:

    //tags for HTML

    and paste in the following code before that block of code:

    //if-then for HTML
    preg_match_all('/\[([a-zA-Z0-9!#%^&*()+=$@._-|\/?<>~`"\'\s]+),\s*if-then=/i', $html_treated, $matches_var, PREG_PATTERN_ORDER);
    preg_match_all('/,\s*if-then=([^\]]*)\]/i', $html_treated, $matches_val, PREG_PATTERN_ORDER);
    preg_match_all('/(\[[a-zA-Z0-9!#%^&*()+=$@._-|\/?<>~`"\'\s]+,\s*if-then=[^\]]*\]/i', $html_treated, $matches_all, PREG_PATTERN_ORDER);
    $matches_var = $matches_var[1];
    $matches_val = $matches_val[1];
    $matches_all = $matches_all[1];
    for($i=0;$i<count($matches_var);$i++)
    {
        $field = $matches_var[$i];
        $field_value = $matches_val[$i];
        $fallback = "";
        $tag = $matches_all[$i];
    
        //if subscriber has no custom fields, use nothing (e.g. fallback=nothing)
        if($custom_values=='')
            $html_treated = str_replace($tag, $fallback, $html_treated);
        //otherwise, replace custom field tag
        else
        {
            $q5 = 'SELECT custom_fields FROM lists WHERE id = '.$subscriber_list;
            $r5 = mysqli_query($mysqli, $q5);
            if ($r5)
            {
                while($row2 = mysqli_fetch_array($r5)) $custom_fields = $row2['custom_fields'];
                $custom_fields_array = explode('%s%', $custom_fields);
                $custom_values_array = explode('%s%', $custom_values);
                $cf_count = count($custom_fields_array);
                $k = 0;
    
                for($j=0;$j<$cf_count;$j++)
                {
                    $cf_array = explode(':', $custom_fields_array[$j]);
                    $key = str_replace(' ', '', $cf_array[0]);
    
                    //if tag matches a custom field
                    if($field==$key)
                    {
                    //if custom field is empty, use fallback
                    if($custom_values_array[$j]=='')
                        $html_treated = str_replace($tag, $fallback, $html_treated);
                    //otherwise, use the custom field value
                    else
                        $html_treated = str_replace($tag, $field_value, $html_treated);
                    }
                    else
                    $k++;
                }
    
                if($k==$cf_count)
                $html_treated = str_replace($tag, $fallback, $html_treated);
            }
        }
    }
    

    In w.php and test-send.php files find the same //tags for HTML line of code, and insert the following code above it. This will allow the if-then code blocks to display properly when testing the email.

    //if-then for HTML
    preg_match_all('/\[([a-zA-Z0-9!#%^&*()+=$@._-|\/?<>~`"\'\s]+),\s*if-then=/i', $html, $matches_var, PREG_PATTERN_ORDER);
    preg_match_all('/,\s*if-then=([^\]]*)\]/i', $html, $matches_val, PREG_PATTERN_ORDER);
    preg_match_all('/(\[[a-zA-Z0-9!#%^&*()+=$@._-|\/?<>~`"\'\s]+,\s*if-then=[^\]]*\])/i', $html, $matches_all, PREG_PATTERN_ORDER);
    $matches_var = $matches_var[1];
    $matches_val = $matches_val[1];
    $matches_all = $matches_all[1];
    for($i=0;$i<count($matches_var);$i++)
    {
        $field = $matches_var[$i];
        $fallback = $matches_val[$i];
        $tag = $matches_all[$i];
        //for each match, replace tag with fallback
        $html = str_replace($tag, $fallback, $html);
    }
    

    With these bits of code installed, now if you use the tag [Field,if-then=] the html that follows the if-then= will only display if the list member has entered data for that custom field.

    So let's say on your sign-up page you want members to be able to select if they are interested in certain topics, like VW, Ford, or Mercedes, you would have each of these topics be a custom field. On you list's sign-up page, if you would include this:

    <input type="checkbox" name="car_vw" value="True">VW<br>
    <input type="checkbox" name="car_ford" value="True">Ford<br>
    <input type="checkbox" name="car_mercedes" value="True">Mercedes<br>
    

    So in your newsletter if you put [car_vw,if-then=We've got a special deal for VWs today!] the deal will only be shown to people who have ticked the VW check box on sign-up.

  • The problem with making custom edits is that it makes keeping up with releases more challenging.. I'm hoping this could be adopted in the core Sendy. @Ben ?

  • Hi @Ben,

    Is there any update on this at all?

    Best,

    Martin

  • PS. It would be useful if both the subject and body could be amended - as then this would enable a form of A/B testing to be run as well. Two birds with one stone :)

  • @Ben

    Is there an update on this? The feature request is now well over 12 months old and it's impossible to do any a/b testing or content segmentation without it.

    This leaves Sendy well behind other email tools currently.

  • +1 for this feature

  • Another +1

  • Does this code still works? Thanks and +1 to be incorporated to the core.

  • +1. Is the contribution from @jlist_sendy possible to add in? It seems like this would be a feature that would not affect current functionality, if added, making it lower risk..

  • I would like to bump this up again. I think this is essential, just for "Dear Mr. xxx" and "Dear Mrs." (or german equivalents).

  • +1 - I have an email list of people who have entered our literary competitions, and I want to send a slightly different email to those who have entered two or more contests.

    What I think is needed is a simple test on a field value which could easily incorporate any boolean logic (with the ability to set the value in the testing emails) generically being [IF:FIELD COMPARATOR VALUE]...[ENDIF] so we could have [IF:COMPS>2]Thanks for being a great supporter![EndIF] or [IF:CAR="Diesel"]Test drive our latest electric car[ENDIF] then test with a prompt asking "Value for COMPS:" and "Value for CAR:" etc.

    Like the commenters above I wouldn't want to put in custom code and have to re-do it (and re-test it) every time Sendy updates. I know this is an old thread but it seems a fair few people would love this feature.

  • What about support TWIG? Similar like EasySendy is using
    https://easysendy.com/docs/use-twig-email-templates/

  • I would also like to comment on this. Sendy Team, are you reading this? It this something you guys are working on? Can we expect it in the near future? I think it's a must have for any mail-tool and you have (sorry for saying) the perfect example in the link above from MailC****.

  • Another +1 from me. This is a rather basic feature and I am surprised that Sendy does not offer it, yet.

  • Just a reminder: This is a really important feature AND it is easy to implement. Please, please, pleaaaase!

  • What is the progress on this?

  • Just another bump, +1 for this feature. Can someone from Sendy let us know if this is on any roadmap? Is there any roadmap at all so we can see what is coming?

  • I'd also like to add my vote for this feature. It would help make the emails more engaging if they are more personalised.

  • +1 for this feature.. Please do implement this

  • +1 for this feature

  • I am new to Sendy (I came from another product) and one of the reasons why I purchased a license is to be able to use a feature like this (which I assumed could be done via List segmentation + Custom Fields), but now I realized this is not implemented.

    +1 for this feature

  • This post is from 2013 and still, nothing close to this has been developed.

    No plans to do it?

    If not, then how can we extend the code?

    Any extensions or anything similar?

    Thanks.

  • +1 please

Sign In or Register to comment.