Every email marketer wants to be able to directly track sales generated by a specific campaign. Commonly used metrics such as open rates and click rates are only rough proxies for the measures that really matter – purchase conversion and total sales. In this blog post, we will explore how to use the Canopy Labs R Console to assess and compare email campaign performance.

Setting up the test

The precondition to assess campaigns based on revenue is to combine purchase data with email engagement data. These are two of the most popular forms of data that our customers upload into the Canopy Labs platform through our Import interface.

To begin, choose which emails to test. Some stores use the tool to compare performance of recent email newsletters. Others want to determine the result of an A/B segmentation campaign so they can learn how to market more effectively. Once you have chosen the emails to test, find their corresponding campaign IDs, either through individual customer profiles on the Canopy Platform (see below) or on your email marketing platform.

Example from a customer profile


The next step is to set the time lag variables that will determine whether or not a sale should be attributed to an email campaign. For example, we typically attribute a sale to a campaign if a customer opens or clicks within 5 days of receiving the email, and then makes a purchase within 2 days of that open or click.

Below is the portion of code that can be modified and entered into the R Console to set the email IDs and choices of time lag variables:

# Load customer collection
customers <- canopy.import("customers")

# Enter email IDs to analyze in the list, each with "quotes"
# You can choose as many email IDs as you like

# Set the time lag from receiving an email to opening or clicking
campaignlag = 5;

# Set the time lag from clicking an email to making a purchase
clicklag = 2;

# Set the time lag from opening an email to making a purchase
openlag = 2;

The below link contains the full set of R code that can be used actually run the analysis of email campaign performance and print the results. Simply copy this code, paste into the R Console, change the variables at the begging of the script to your desired values, and hit “Submit”. The script will run and print the results when finished.

Email campaign success tracking

Analyzing Results

The code prints a set of results in the output screen on the R Console that indicate campaign performance. For each campaign, the following data is displayed:

  1. Customers: the script prints the IDs of the customers that made purchases from this campaign. Try entering one of these customer IDs into the Browse Customers interface to see their full action history.
  2. Engagement counts: the next 4 numbers show the number of customers who received the email, opened, clicked, and made a purchase.
  3. Conversion rates: the next 3 numbers show the open rate, click rate, and purchase rate generated by the campaign (interpret these as percentages).
  4. Sales generated: finally, the last number shows the total dollar value of all sales generated by the campaign.


As you can see, running email campaign performance analytics through the Canopy Labs R console is quick and flexible. Give it a try to today, and start learning more about which campaigns are working and how you should optimize email marketing going forward! If you need any help, let us know in the comments below.