## Introduction
In today’s data-driven advertising landscape, understanding the Return on Ad Spend (ROAS) at a granular level, such as by region, is crucial for optimizing marketing budgets and strategies. For Data & Analytics teams in startups or growing companies, manually compiling ROAS reports across multiple regions can be tedious, error-prone, and time-consuming. Automating this process not only saves valuable time but also ensures real-time insights for decision-makers.
This article provides a detailed, step-by-step guide on how to automate the reporting of ad campaign ROAS by region using **n8n**, an open-source workflow automation tool. The workflow will integrate with advertising platforms (e.g., Google Ads, Facebook Ads), Google Sheets for data storage, and Slack for report dissemination. By following this guide, your team will receive automated, region-wise ROAS reports, enabling faster, data-backed marketing decisions.
—
## What Problem This Automation Solves
– **Manual data collection** across ad platforms for each region is cumbersome
– **Data inconsistencies and delays** in reporting reduce decision agility
– **Lack of real-time insights** into campaign performance per region
**Beneficiaries:**
– Data & Analytics teams who build marketing dashboards
– Marketing managers making regional budget allocations
– Stakeholders needing frequent campaign ROI visibility
—
## Tools and Services Integrated
– **n8n**: for building the automation workflow
– **Google Ads API**: source of campaign metrics including cost and conversions
– **Facebook Marketing API** (optional): for aggregating Facebook Ads ROAS if needed
– **Google Sheets**: storing processed data and hosting reports
– **Slack**: for sending notifications and reports to teams
—
## Overview of the Workflow
1. **Trigger**: Scheduled trigger runs daily (or custom frequency) to refresh ROAS data
2. **Fetch ad campaign data** from Google Ads (and optionally Facebook Ads)
3. **Filter and aggregate data by region** (using campaign location targeting data or labels)
4. **Calculate ROAS per region** (Revenue / Ad Spend)
5. **Update Google Sheets**: write the ROAS data to a shared spreadsheet
6. **Send Slack notifications** with summarized ROAS report
—
## Step-By-Step Technical Tutorial
### Prerequisites
– An n8n instance running (self-hosted or via cloud service)
– Access credentials and API tokens for Google Ads API and Facebook Marketing API
– Google Sheets API credentials with access to a pre-created sheet for reports
– Slack App credentials with permission to post messages
### 1. Setting Up the Workflow Trigger
– Use the **Cron** node in n8n to schedule daily executions (e.g., every day at 8 AM)
– This scheduler initiates data fetching and reporting
### 2. Fetching Campaign Data from Google Ads
– Use the **HTTP Request** node to query the Google Ads API
– Endpoint: Google Ads “googleads.googleapis.com/vX/customers/{customerId}/googleAds:search”
– Query:
“`sql
SELECT campaign.id, campaign.name, segments.geo_target_country, metrics.cost_micros, metrics.conversions_value
FROM campaign
WHERE segments.date DURING LAST_7_DAYS
“`
– Explanation:
– Retrieve campaign cost and conversion value (revenue) by country/region over the past week
– Cost is in micros (millionths of currency unit), convert by dividing by 1,000,000
– Authentication:
– Use OAuth2 credentials in n8n to authorize this request
– Handle pagination if the response is large
### 3. (Optional) Fetching Facebook Ads Data
– Similar to Google Ads, use the Facebook Marketing API with the **HTTP Request** node
– Fetch ads insights grouped by region
– Merge or keep data separate depending on reporting needs
### 4. Data Aggregation and ROAS Calculation
– Use the **Function** node (JavaScript) in n8n to:
– Parse the fetched data
– Aggregate cost and conversion value metrics by region
– Calculate ROAS as `(conversion_value) / (cost)`
Example Function Node Script:
“`javascript
const results = {};
for (const item of items) {
const region = item.json[‘segments.geo_target_country’];
const cost = item.json[‘metrics.cost_micros’] / 1e6;
const revenue = item.json[‘metrics.conversions_value’];
if (!results[region]) {
results[region] = { cost: 0, revenue: 0 };
}
results[region].cost += cost;
results[region].revenue += revenue;
}
return Object.entries(results).map(([region, data]) => ({
json: {
region,
cost: data.cost,
revenue: data.revenue,
roas: data.revenue / data.cost || 0
}
}));
“`
### 5. Writing to Google Sheets
– Use the **Google Sheets** node in n8n to write the aggregated data
– Target sheet columns: Region | Cost | Revenue | ROAS
– Choose between append (for daily logs) or overwrite mode (for current report)
– Configure the node:
– Authentication with Google Sheets OAuth2
– Target specific spreadsheet and worksheet
– Map fields from function output
### 6. Sending Slack Notifications
– Use the **Slack API** node or **HTTP Request** node with Slack Webhook URL
– Format a message summarizing ROAS by region
– Example message:
“`
*Daily Ad Campaign ROAS Report*
Region: US, ROAS: 4.5
Region: Canada, ROAS: 3.2
Region: UK, ROAS: 5.0
“`
– Send message to a dedicated Slack channel for marketing or analytics
—
## Common Errors and Tips for Robustness
– **API Rate Limits**: Google and Facebook APIs have rate limits. Implement error handling and retry strategies using n8n’s built-in features.
– **Data Gaps or Missing Regions**: Ensure the API query date range aligns with reporting needs and consider defaulting missing values to zero.
– **Authentication Failures**: Keep OAuth tokens refreshed; using n8n’s OAuth2 credential node helps maintain connectivity.
– **Data Type Mismatches**: Cost is often in micros; always convert correctly to avoid erroneous ROAS calculations.
—
## How to Adapt or Scale This Workflow
– **Add more ad platforms**: Integrate Twitter Ads, LinkedIn Ads APIs similarly
– **Granular segmentation**: Drill down from country to city or state level if APIs permit
– **Real-time updates**: Move from daily to hourly triggers for near real-time monitoring
– **Enrich data with CRM**: Pull additional customer conversion data from HubSpot or Salesforce
– **Visual dashboards**: Integrate with BI tools (Google Data Studio, Tableau) by exporting data from Google Sheets
—
## Summary
Automating the reporting of ad campaign ROAS by region using n8n creates a reliable, scalable, and timely reporting process that empowers Data & Analytics teams to provide actionable insights quickly. By integrating key ad platforms, data storage, and team communication tools in a cohesive workflow, startups can make their marketing spend more efficient and transparent.
The general principles outlined are adaptable to multiple ad channels and reporting needs, making this workflow a powerful foundation for automated campaign analytics.
—
## Bonus Tip
Implement **error alerting** within the workflow by monitoring node failure events and sending Slack alerts whenever the data fetch or processing fails. This ensures immediate awareness of issues, maintaining report reliability without manual oversight.
—
This article equips you with the exact steps to build this automation in n8n—empowering your team to streamline ad performance tracking and focusing on optimizing the marketing ROI rather than manual reporting.