n8n workflow

Aggregate Campaign KPIs and Detect Cost Deviations Automatically

Structured campaign results are easy to analyze: The workflow receives campaign data via webhook, validates inputs, groups by channel, and automatically calculates key KPIs such as CPC and CPA. It also checks if target values like Target CPA are exceeded. The output is a reporting object ready for further processing or visualization. Invalid inputs are clearly rejected. Especially suitable for marketing teams and agencies regularly analyzing campaign performance.

Marketing teams, agencies, and analysts seeking to regularly analyze and compare campaign data from multiple channels will benefit from this structured workflow. Once imported into n8n, it provides a webhook that accepts POST requests with campaign data (for example, from BI tools, CRM, or manual exports). The data is validated, grouped by channel, and key KPIs are automatically calculated: Cost-per-Click (CPC), Cost-per-Acquisition (CPA), and target achievement compared to an optional Target CPA. The result is a structured JSON report suitable for dashboards, monitoring, or further automation steps. Invalid or incomplete inputs receive a clear error message. Before going live, webhook authentication in n8n must be enabled to prevent unauthorized access. Since execution data may contain sensitive information, it should be managed accordingly. The workflow is flexible for different data sources but requires adherence to the specified input format.

Aggregate Campaign KPIs and Detect Cost Deviations Automatically
AI-generated image

Installation

1. Import the workflow into n8n. 2. Save the workflow. 3. Start the test listener and use the displayed test URL of the webhook node. 4. Send a POST request with Content-Type application/json to the test URL (see example below). 5. Check the response and adjust the input format if necessary. 6. After successful testing: publish/activate the workflow and use the production URL from the webhook node. 7. Set up webhook authentication in n8n to prevent unauthorized access. 8. Optionally: configure retention and access to execution data in n8n.

Usage

1. Example of a valid request: ```json { "rows": [ {"channel": "Google Ads", "spend": 100, "clicks": 50, "conversions": 5}, {"channel": "Meta", "spend": 80, "clicks": 40, "conversions": 4} ], "targetCpa": 18 } ``` Expected response: ```json { "status": "success", "report": [ {"channel": "Google Ads", "spend": 100, "clicks": 50, "conversions": 5, "cpc": 2, "cpa": 20, "aboveTarget": true}, {"channel": "Meta", "spend": 80, "clicks": 40, "conversions": 4, "cpc": 2, "cpa": 20, "aboveTarget": true} ], "totals": {"spend": 180, "clicks": 90, "conversions": 9} } ``` HTTP status: 200 2. Example of an invalid request (empty rows array): ```json { "rows": [] } ``` Response: ```json { "status": "error", "message": "rows muss ein nicht-leeres Array sein." } ``` HTTP status: 200 3. The fields spend, clicks, and conversions must be numeric and >=0. Channel must not be empty. 4. Webhook authentication must be enabled separately in n8n. 5. Execution data is stored in n8n and should be regularly reviewed and managed.

Required connections and APIs

API connections

No saved API credentials were detected in the workflow JSON. Still check webhooks, target systems, credentials, and data protection before activation.

Nodes
WebhookCodeRespond to Webhook

Isolated functional test passed

Optional isolated functional test

The isolated data flow was tested without external services or credentials.

5 tests passedShow tested casesHide tested cases
Standard case with complete dataChecks the complete standard flow with valid sample data.Isolated functional test passed
Variation or boundary caseChecks a valid variation or an important boundary case.Isolated functional test passed
Additional processing ruleChecks this workflow's additional business processing rule.Isolated functional test passed
Invalid or incomplete inputChecks that invalid or incomplete data is rejected safely.Isolated functional test passed
Empty inputChecks that an empty request receives a controlled response.Isolated functional test passed

Buyer feedback

Reviews

No reviews yet.

Back to product