Build a scalable pricing and billing system like Klaviyo, the email marketing and SMS automation platform, with various price points to meet the needs of all your customers.
What's in it for you?
In this article, you will learn how to build a ‘pay-as-you-go’ billing system based on a tiered pricing model.
This template is suitable for companies whose pricing fully depends on usage, such as API companies and marketing platforms that want to charge their customers only for what they need.
What's the secret sauce?
With Klaviyo, there is no annual contract. Customers can use the platform to send emails and SMS to their contacts and the two products have independent price lists.
Email service (total monthly cost)
SMS service (total monthly cost)
Tier 1 (free tier)
$0 up to 250 contacts
$0 up to 50 contacts
$20 up to 500 contacts
$5 up to 150 contacts
$30 up to 1,000 contacts
$10 up to 250 contacts
$45 up to 1,500 contacts
$20 up to 500 contacts
$60 up to 2,500 contacts
$30 up to 750 contacts
$70 up to 3,000 contacts
$40 up to 1,000 contacts
Klaviyo’s customers can choose to use only the email service, or SMS service, or they can use both.
We are going to teach you how to replicate this pricing with our billing solution.
What do you need?
The first thing to do is to create your company account on Lago Cloud or deploy Lago Open Source on your existing infrastructure. In both cases, you should ask a back-end developer to help you with the setup.
Our documentation includes a step-by-step guide on how to get started with our solution.
Step 1 – How to calculate the number of email contacts
Lago monitors consumption by converting events into billable metrics. For Klaviyo, there would be two billable metrics based on the number of email and SMS contacts.
For the email service, customers are charged depending on the total number of email contacts, which means that we need to know the maximum number of contacts that are managed by each customer each month.
Through the user interface, we are going to create a billable metric called ‘Email contacts’ and select the ‘max’ aggregation type. This method requires a property, which we will define as ‘total_nb’.
We will use this billable metric as follows: at the end of each day, our back-end system will generate an ‘email_contacts’ event for each customer, including the total number of email contacts.
At the end of the billing period, Lago will go through the list of events received for each customer and identify the maximum value for the property ‘total_nb’ among all events. This value will then be used to calculate the amount owed by the customer for the email service.
Step 2 – How to calculate the number of SMS contacts
For the SMS service, customers are charged depending on the number of SMS contacts. However, Klaviyo does not calculate the total number of contacts. On its website, the marketing platform explains how the number of SMS contacts is computed:
“This number represents the actual number of SMS contacts you plan to message in a month. It doesn’t represent your total number of SMS contacts, since you might not message every contact in a given month.”
Therefore, for this second billable metric, we are going to use the ‘count unique’ aggregation type and will define ‘contact_id’ as the event property.
In this case, the aggregation type is metered. It means the aggregated amount is reset to 0 at the beginning of the next billing cycle.
Each time an SMS is sent, our back-end system will generate an ‘sms_contacts’ event, including the ‘contact_id’ property.
At the end of the billing period, Lago will go through the list of events received for each customer and determine the number of unique contacts, based on their ID. If a contact receives two SMS during the month, they will only count as one paying contact.
Step 3 – How to set up tiered pricing
Now that we have our two billable metrics, we can configure our plan.
First, we need to define the plan model, including billing frequency and subscription fee: we can select the monthly billing period and as our pricing is ‘pay-as-you-go’, there is no subscription.
Customers will only pay for their use of the email and SMS services, which are defined as charges.
Each charge is associated with a billable metric and has its own pricing structure. In order to replicate Klaviyo’s pricing, we will select the graduated charge model, which will allow us to define as many tiers as we want for our services.
The graduated charge model is generally used to define a unit price for each tier. However, Klaviyo’s pricing is rather based on packages of units which all have different prices. Therefore, it is more appropriate for us to define a flat fee for each tier instead of a unit price.
As tiers add up, the flat fee for each tier should only represent the price difference with the previous tier.
We have defined six tiers to illustrate this step but you can create as many tiers as you want with the graduated charge model.
Finally, we apply the same method to our second charge and our pricing plan is ready.
For marketing companies like Klaviyo, tiered pricing is a good option to help customers understand how fees may change as their business grows.
With Lago, you can create your own billable metrics and use the graduated charge model to adapt this template to your products and services.