Getting Started with Optimail


Building an automated, self-optimizing email campaign with Optimail is easy. If your messages are already drafted, you'll be up and running within about 30 minutes.

This guide walks you through building your first campaign, from defining the customer events that are relevant to your campaign, drafting your campaign messages, setting your campaign's goals, and integrating Optimail with your existing website or app.


Events are actions that a customer may perform that you would like to track. Every Optimail campaign begins with several default events that are relevant to email marketing campaigns (opening emails, clicking links, purchasing, and unsubscribing), but Optimail works best when you add custom events that are more relevant to your business.

Events have three main purposes:

  1. Subscription Triggers. Events can be used to subscribe a customer to a campaign based on their activity. For example, you can add a customer to your Onboarding campaign after they first log in to your application's dashboard. Events will only subscribe a customer to a campaign the first time they are performed.

  2. Email Constraints. Events can be used to constrain the emails sent in a campaign. For example, you may want to send a message offering technical support if you notice a customer hasn't finished configuring your app after 3 days. To do so, you can tell Optimail not to send this message unless it's (1) after day 3 and, (2) the customer hasn't logged a "configured" event. From there, Optimail will learn exactly when to send the message so that it's most effective, but these basic constraints can help it learn faster.

  3. Goals. Events can be used as campaign goals. For example, the goal of an Onboarding campaign may be to get your user to upgrade their subscription. You can add an "upgraded" event, set it as a goal of the campaign and, when a customer subscribed to your campaign triggers this event, Optimail will take note that the campaign had a positive impact on this customer. This helps shape what Optimail does for future customers, and make your campaigns more effective.

Adding Events

Add your first custom event by going to the Events tab and clicking + New Event.

Here we're adding a custom event, “Logged in to profile”, which is triggered when customers have logged in to their profile.

Triggering Events


One way to trigger an event is make an event call to the Optimail API. To do so, you'll need to add an API call that sends the event name to your website/app (see the Integration section below for more details.)

URL / Context String Matching

A second way to trigger an event is by specifying a “Context String Match” for a context string (i.e., a URL or app view name). This allows you to add new events from the Optimail dashboard without having to add new code to your website/app.

We set up the 'Logged in to profile' event to trigger when a user reaches

Add as many custom events as you would like. Later, you can use these to set up goals and subscription triggers for your campaigns!


By integrating Optimail, you unlock three powerful functions:

  1. Pushing customer profiles in real-time to Optimail, allowing you to track their events and subscribe them to campaigns.

  2. Tracking events in your website or app, allowing Optimail to learn from customer responses and behaviors that occur when they browse your website, or engage with your app.

  3. Subscribing customers to campaigns, allowing Optimail to begin emailing your customers automatically.

Is integration required to use Optimail?

No. Optimail does not require integration with your website or app; however, without integration, using Optimail has more limited functionality:

  • Customers would only be be imported manually via CSV files or manual entry into the dashboard.
  • Optimail would only track events related to emails, such as opens, clicks, and unsubscribes.
  • Customers would have to be manually subscribed to your campaigns via the dashboard.

Configuring the Optimail API

To integrate Optimail with your website or app, you will need to configure the Optimail API.

Configuring the Optimail API may vary depending on the your app or website; however, the majority of our users connect to Optimail using our Javascript library that provides a simple piece of code you drop in your site.

If you would like to use the Javascript API, continue below. If you would like to learn how to make Optimail API calls from PHP, Python, or another language, please skip to the "Using Other Languages to Connect to the Optimail API" section below.

Using the JavaScript Library

To integrate the JavaScript API, first access your dashboard and click the Integrate tab so that you can copy-and-paste code snippets directly to your website. From there, integration involves 3 easy steps:

  1. Paste the JavaScript snippet just above the </body> tag of your website. The snippet includes your API ID and can be pasted directly as-is.

  2. For each of your events, paste the event code above the JavaScript snippet on the event-triggering pages.

  3. On pages where your customer is logged-in, paste the identify code. Make sure that you substitute the example data with your customer's real customer data.

  4. If you would like to subscribe customers to a campaign when they reach a certain page, paste the subscribe code above the JavaScript snippet.

Single-page Apps

The snippets pasted above are automatically executed when your page first loads. If you built your website as a single-page app and want to invoke these commands with different timings, you will need to access the underlying JavaScript API methods directly using window.optimail.view(), window.optimail.event(), window.optimail.identify(), and window.optimail.subscribe().

Using other languages to connect to the Optimail API

Please visit our REST API documentation for full API specification, code examples in your language, and request/response examples.

Future Integrations

We are presently building integrations with other services, such as Intercom and Segment, that will connect with Optimail with you having to install anything on your site!


Campaigns are collections of messages you want to send to customers in order to drive them toward a goal. Once created, Optimail's job is to learn when, what, and who to message in order to make this campaign most effective.

Creating a Campaign

Create your first campaign by clicking + New Campaign from the Campaigns tab. Specify a name and subscription duration.

The Name is a private name for this campaign to help you stay organized.

The Subscription Duration represents the maximum amount of time a customer will be subscribed to this campaign. A customer may exit a campaign earlier, if they perform a terminal action (e.g., unsubscribe) or if Optimail determines that it's more effective to send messages earlier.

Add your messages

Click Create new email to begin creating the content that you want to send to your customers.

Optimail will try different emails and orders to figure out what works best. If you want to impose any constraints on what Optimail tries, you can do so in the Delivery Rules. Here are a few examples of the types of rules are able to specify:

  • Day-based rules: 'Always send this message on day 1', or 'Always send after day 10'
  • Message-based rules: 'Always send this message after Welcome Message is sent'
  • Event-based rules: 'Don't send this message until customer has Logged in to profile'
  • Segment-based rules: 'Only send this message to Enterprise customers'

Next, edit the subject and body of the message. This is perhaps the most important part of any campaign because these messages are Optimail's tools to driving customers towards your goals! Note that you can customize messages to your customer using merge tags in the body and subject of your email, such as {{FIRST_NAME}} and {{LAST_NAME}}. Merge tags are listed to the right of the email editor.

By law, and our terms of service, every email must include an {{UNSUBSCRIBE_LINK}} tag, which is the URL of your unsubscribe page. Customers who click this link will be unsubscribed from your campaign. Anyone found hiding this link or otherwise making unsubscribing difficult will be permanently banned from Optimail.

Performing "A/B tests" with email variations

Testing is a critical element of any successful customer communication campaign. Standard A/B tests consider each email in isolation and require you to make complicated decisions about how to split up your customers. Optimail differs from standard A/B testing by automatically and continually learning which emails work best for which customers in the context of the entire campaign.

To perform this "variation testing", you can create two or more variations of any email in your campaign.

You can create as many variations of an email as you would like - changing the content, subject, and sender. Optimail will automatically learn what works best!

Verifying your custom domain

The first time you specify a custom from email with a new domain, you will need to verify that you own the domain by going to your Account > Profile > Verify Domains (click here to open your Profile page).

Here you will see a list of your custom domains. To verify your domain, find the record needed to add to your DNS and add this to your DNS zone for your domain. Once you have completed this, you can manually re-check the status of the domain. If you do not manually re-check the domain status, Optimail will check it automatically within the hour.

Note that, until this domain is verified, Optimail will not be able to use your custom domain.

Testing your message

You should be absolutely sure that your email looks great before saving it. The easiest way to do so is to to send yourself a test copy of the email to see how it looks in your own inbox!

Activating your message

By default, all new messages are in Draft mode and will not be sent to your customers. This allows you to collaborate on new emails or deactivate old emails within a campaign with the simple toggle of a switch.

If you are happy with your message after saving, simply toggle the message to Live mode. Don't worry: it won't be sent right away. All new campaigns are paused until you activate them manually, too. (You'll do that when we are done setting up the campaign).


Campaign goals can be positive (i.e., something you'd like to happen) or negative (i.e., something to avoid).

Each new campaign is pre-populated with goals that relate to default events:

  • Positive goals: opening emails, clicking email links, and purchasing
  • Negative goals: unsubscribing

If you have added custom events, you can now add them as goals for the campaign. To add a custom goal, click Create a new goal to specify which event underlies this goal. For example, we want the goal of our Onboarding Campaign to be getting customers Logged in to profile.

Delivery Schedule

By default, Optimail will deliver up to 7 messages per week, up to one per day. Optimail will automatically learn when to send messages so that your customers do not get annoyed and unsubscribe; however, you can take things into your own hands by adding firm constraints to the delivery schedule.

Optimail allows you to modify the delivery schedule is to specify the days of the week to send emails (e.g., do not send on Saturdays and Sundays), the time window within which messages are sent (e.g., before 6am and 11pm), and to specify the maximum number number of emails per week that can be sent to an individual customer in a campaign.

There are three important things to consider when modifying the delivery schedule:

  1. As noted, Optimail will learn not to send emails too frequently and annoy your customers, so enforcing these constraints is far from necessary.
  2. Optimail includes a unique time model that learns the best time to send an email within your time window.
  3. All times are indicated with respect to your customer's timezone, not your timezone.


There are three ways to add subscribers to a campaign.

First, customers can be subscribed to campaigns at any time using a subscribe call via the Optimail API. (See the Integration section above).

Second, you can create event triggers that automatically subscribe a customer to a campaign when they perform a particular action (e.g., when they log in, or when they visit a particular page). (See the Events section above).

Finally, third, you can manually add customers to a campaign in the Customers tab, either when importing new customers or when editing a customer's profile.

Next Steps

Now that we've got our campaign set up, we can switch it to active from the Campaigns tab. It will automatically start learning and trying different strategies to drive customers towards the goals we have set up.

Clicking on the campaign from this list takes us to details about the campaign:

In the Overview, we can see a snapshot about the campaign, how long it's been running, how many subscribers we have, and the status of the campaign.

On the Messages tab, we can see basic statistics about the email, such as open, click, bounce, and spam rates. We can also see each email's Optimetric - a statistic that represents how well each email is performing. This statistic will gradually change over time as Optimail learns more about the email, so make sure to check in and see how it's doing!

The Activity tab shows us a timeline of the campaign activity - what Optimail is doing and how your customers are responding.

The Subscribers tab shows us who is in our campaign, and how they have responded. Try sorting by actions to see your best responders!

On the Insights tab, you can see a summary of how Optimail is performing over time. You can expect to see a bit of fluctuation as there's inherent variability in terms of how your customers respond, but you'll want to look for an increase in positive actions and a decrease in negative actions over time as Optimail automatically optimizes your campaign. Keep an eye out for new features to appear in this tab!

Ready to get started? Optimail is free while you build and integrate.