In today's fast-paced sales environment, waiting for end-of-month reports to discover you've missed your targets is a recipe for failure. Sales teams need real-time insights to act decisively, celebrate wins as they happen, and course-correct before small issues become big problems. The manual process of pulling data, crunching numbers in spreadsheets, and sharing updates is slow, error-prone, and unsustainable.
What if you could treat your business performance like a mission-critical service? What if every key metric could trigger an automated alert, just like a server hitting its CPU limit?
This is the power of KPIs as Code, the core philosophy behind KPIs.do. In this step-by-step tutorial, we'll show you how to connect your sales data to KPIs.do, define a crucial "Monthly Sales Growth" KPI, and set up real-time alerts in Slack when your targets are met or missed. Say goodbye to manual reporting and hello to automated performance intelligence.
Before we dive in, let's look at the "why." Automating your KPI tracking with a platform like KPIs.do transforms your entire operational rhythm:
Let's build a real-world integration. Our goal is to receive a Slack notification anytime our monthly sales growth KPI for a specific region falls below a critical threshold.
Prerequisites:
With KPIs.do, your metrics aren't just numbers in a dashboard; they are version-controlled, reusable definitions. This "KPIs as Code" approach brings the discipline of software development to business intelligence.
First, you'd define your monthly-sales-growth KPI within your KPIs.do project. This can be done via the UI or a configuration file (e.g., kpi.yaml) that you can store in your Git repository.
# kpi.yaml
name: monthly-sales-growth
description: "Tracks the month-over-month percentage growth in sales revenue."
dimensions:
- region
- product
alerts:
- name: "Critical Growth Dip"
# Trigger if the value is less than 5%
condition: "value < 5"
message: "🚨 **Critical Alert:** Sales growth for `${region}` has dropped to `${value}%`!"
# The integration endpoint we'll set up in Step 3
sink: "slack-sales-channel"
This simple file establishes the logic for our KPI. It defines its name, what data dimensions it can be sliced by (region, product), and a critical alert that triggers when the growth value is less than 5%.
KPIs.do is API-first. You can connect directly to databases like Snowflake or push data from anywhere using our simple API. For this tutorial, we'll demonstrate pushing a calculated value from a script.
Imagine you have a nightly script that calculates the sales growth from your CRM or internal database. All you need to do is add a few lines of code to send this data to KPIs.do.
Here’s a TypeScript example using the kpis.do SDK:
// Import the KPIs.do client
import { kpis } from 'kpis.do';
// This function would contain your business logic to get the latest sales data
async function calculateSalesGrowth(region: string, product: string): Promise<number> {
// ...your logic to connect to a CRM, database, or data warehouse...
// For this example, let's return a hypothetical value
return 4.2; // A value below our 5% threshold
}
async function trackGrowthKPIs() {
const currentGrowth = await calculateSalesGrowth('North America', 'Enterprise Plan');
// Track a new data point for our pre-defined KPI
const result = await kpis.track({
name: 'monthly-sales-growth',
value: currentGrowth, // The calculated growth percentage
dimensions: {
region: 'North America',
product: 'Enterprise Plan'
}
});
// The KPIs.do platform handles the rest!
console.log(`Tracking result: ${result.status}`);
if (result.alerts?.length > 0) {
console.log(`Alerts triggered: ${result.alerts.length}`);
}
}
// Run the tracking function
trackGrowthKPIs();
In this script, we calculate the growth (here, a static 4.2%) and send it to KPIs.do using kpis.track(). We tag it with the correct name and dimensions. Our work here is done—KPIs.do takes over to check for alerts.
Now, let's tell KPIs.do where to send the alert.
Your platform is now connected. Any alert configured to use the slack-sales-channel sink will be sent to your Slack channel.
When your script from Step 2 runs, the following happens automatically:
Within seconds, your Slack channel lights up with a real-time, actionable insight:
🚨 Critical Alert: Sales growth for North America has dropped to 4.2%!
Your team can now immediately huddle to diagnose the issue, long before it shows up on a formal monthly review.
This pattern is incredibly powerful and repeatable. Once you have the framework in place, you can apply it to any metric that drives your business. Think about automating alerts for:
By defining your performance metrics as code, you can build a robust, automated, and scalable business monitoring system.
Ready to stop chasing data and start driving results? Sign up for KPIs.do and turn your business metrics into measurable, automated services today.