Emma is a bot that predicts the performance of Salesforce email marketing campaigns.
Emma uses the k-nearest neighbors machine learning algorithm to make predictions about the performance of email campaigns.
To train Emma, create a new instance of Emma
and pass to the constructor the path to your Salesforce tracking data spreadsheet. The path to your tracking data spreadsheet is relative to the directory in which Emma lives.
$emma = new Emma\Emma('salesforce_tracking_data.csv');
Emma uses the .csv
spreadsheet generated by Salesforce Marketing Cloud's Recent Send Summary Report.
You'll need to export your tracking data from Salesforce and save the spreadsheet to a folder on your computer or web host that can be read by Emma.
Before using Emma, you'll need to tell PHP to automatically detect line endings in spreadsheets—otherwise, the data may not be read correctly.
You'll also need to set the timezone to America/Indiana/Indianapolis
to ensure Salesforce timestamps are processed correctly.
ini_set('auto_detect_line_endings', true);
date_default_timezone_set('America/Indiana/Indianapolis');
Emma's predict
method can be used to predict the performance of an email campaign.
The predict
method takes 3 arguments:
$segment_size
: An integer representing the number of people to which the email campaign will be sent.$day_of_week
: An integer between0
(Sunday) and6
(Saturday) representing the day of the week on which the email campaign will be sent.$hour_of_day
: An integer between0
and23
representing the hour of the day on which the email campaign will be sent.
$segment_size = 600;
$day_of_week = 3;
$hour_of_day = 15;
$prediction = $emma->predict($segment_size, $day_of_week, $hour_of_day);
The predict
method returns an array containing two decimal values: the predicted open rate percentage and the predicted click-through rate percentage. Values are rounded to the nearest hundredth.
[51.52, 8.59]
- Emma requires a training data set containing hundreds (if not thousands) of email campaigns before it's able to make reasonably-accurate predictions.
- Emma doesn't account for other aspects of an email campaign that affect its performance, including subject line and message copy, content length, number of images in the message, or number of previous sends in the campaign.
- Emma doesn't account for audience demographic information (ex. prospective students, alumni, faculty and staff).
- Emma might be more accurate using a different machine learning algorithm, or different data pre-processing steps such as applying one-hot encoding to the
hour_of_day
andday_of_week
features.