Returns a random number.

 float random( [ integer limit ] )

If called with no parameters, returns a floating-point number between 0.0 and 1.0.

If called with a single parameter, an integer, returns an integer between 0 (inclusive), and that number (exclusive). So for example, random(8)returns an integer in the range 0-7.


{if random() < .3} 
<p>There is a 30% chance that this section will appear in the message.</p> 

Randomly Select Subject Lines from Content Feed Titles and Test Performance

Use Case: If you have ten pieces of content in a data feed, generate a random number between 0-9 to randomly assign a subject line to users in order to see which performs best.


{randNum = random(10)}
{subjectLine = content[randNum].title}

Then, check the Campaign Summary Page to see which performed best!

Explanation: This script creates a local variable (called “randNum”), which equals a randomized value between 0 and 9 (this value will randomize for each user). Separately, the “subjectLine” assignment references that number in order to randomly pull in one of the content array’s titles to act as the subject line.

Set Random Variable on Users for Future Cohort Testing

Use Case: Use in conjunction with Sailthru Trigger functionality to set a value between 0-9 on users upon receipt of a Welcome transactional. This allows you to pre-segment out your users immediately for down-the-line testing (ex. Exclude everyone with “welcome_segment = 0” from the rest of the Welcome Series or a Reengagement Series as a testing benchmark). Used in conjunction with “random()”

Zephyr: {api_user({"vars": {"welcome_received": random(10)}})}

zephyr example welcome_received 3


This script uses the api_user() function to set a custom field (var called “welcome_received”) on a user upon receipt of a transactional template (in this scenario, a Welcome email). For user segmentation purposes, the script also uses random() to create a randomized value between 0-9 upon receiving this transactional. This is beneficial for future cohort testing as you’ll have pre-established user buckets.