Marketing campaign analysis: Measuring ROI with KNIME

Introduction

Hi, I am Akira, the editor-in-chief of Data Without Code. First of all, huge congratulations! If you have followed our tutorials up to this point, you have officially graduated from our Automation Hacks module. You know how to extract data from anywhere—APIs, SQL databases, and even PDFs.

You have the technical skills. Now, it is time to use them to generate real business value.

Welcome to the Use Cases module. In this phase of our DX journey, we are going to solve actual corporate problems. And there is no problem bigger than the one faced by every marketing department in the world: Proving the ROI (Return on Investment) of their campaigns.

In this tutorial, I will show you how to blend your marketing spend data with your actual CRM sales data to build a fully automated ROI calculator in KNIME Analytics Platform.

The Problem: Siloed Marketing Data

Why is calculating ROI so hard in Excel? Because the data lives in two completely different places.

Your marketing team spends money on Facebook Ads, Google Ads, and LinkedIn. That “Ad Spend” data is usually downloaded as a CSV. Meanwhile, the actual “Revenue” generated from those clicks lives inside your CRM (like Salesforce).

If you want to know if a $5,000 ad campaign actually made money, you have to export both datasets, clean them, and run massive VLOOKUPs to match the Campaign IDs. Let’s automate this.

Step 1: Bring in Both Datasets

First, we need to load both data sources into KNIME. Add two CSV Reader nodes to your canvas (or use the DB Reader if your CRM is connected via SQL).

  • Top Node: Read your “Marketing Spend” data (Columns: Campaign ID, Channel, Ad Spend).
  • Bottom Node: Read your “Sales Revenue” data (Columns: Order ID, Campaign ID, Revenue).

Step 2: Aggregate the Sales Data (GroupBy)

Before we can join the data, we have a problem. The Sales Revenue dataset lists every single individual order. We need to know the Total Revenue per campaign, not the individual orders.

We solve this using the GroupBy node we mastered in our Data Prep module.

Connect a GroupBy node to your Sales data. Group by “Campaign ID”, and in the Manual Aggregation tab, select “Revenue” and set it to Sum. Execute the node. You now have a clean list showing exactly how much money each campaign generated in total.

Step 3: Blend the Data (Joiner Node)

Now we bring the cost and the revenue together. If you remember our early guide on how to do VLOOKUP in KNIME, you know exactly what to do.

Add a Joiner node. Connect the “Marketing Spend” data to the top port, and your newly aggregated “Sales Revenue” data to the bottom port. Double-click the node and join them by the matching “Campaign ID” column. Use a Left Outer Join to ensure you don’t lose any campaigns, even if they generated zero sales.

Step 4: Calculate the ROI (Math Formula Node)

Your data is now blended into one table: Campaign ID, Channel, Ad Spend, and Total Revenue. It is time for the final calculation.

The standard formula for Marketing ROI is: (Revenue - Ad Spend) / Ad Spend.

To do math in KNIME, we use the Math Formula node. Connect it to your Joiner output and double-click to open it.

  1. In the “Expression” box, double-click your columns to build the formula: ($Total Revenue$ - $Ad Spend$) / $Ad Spend$.
  2. Check the “Append Column” box at the bottom and name it “ROI”.
  3. Execute!

(Akira’s Pro-Tip: Multiply the entire formula by 100 to get a clean percentage format like 150% instead of 1.5!)

Conclusion: Your Next Steps

Congratulations! You have just built a robust, automated Marketing ROI engine. You can now instantly tell your marketing director which channels (like Google or LinkedIn) are generating a 200% return, and which ones are burning cash.

If you want to make this even more impressive, you can highlight the top-performing campaigns automatically using the Top k Selector node and email the results straight to the CMO.

Calculating past ROI is critical for reporting. But what if you want to look into the future? What if your CEO asks you: “Based on our current data, how much revenue will we generate next month?”

Are you ready to transition from data analysis to predictive modeling? Join me in our next Use Case tutorial where I show you how to build a simple sales forecasting model in KNIME!

Copied title and URL