Optimize Klaviyo campaign send times and email reports with Gmail
Ready for 3.0What this workflow does
This workflow has 11 nodes and runs on a schedule (every week at 08:00) (plus 1 other trigger). Along the way it connects Gmail. It also calls a.klaviyo.com over HTTP.
How it runs
Trigger: On a schedule (every week at 08:00) (plus 1 other trigger).
- Config (Edit Fields (Set)): sets 4 fields: lookback_days, min_campaigns_per_slot, start_date…
- Gmail: uses Gmail
- Get Sent Campaigns (HTTP Request): calls an HTTP API
- Flatten Campaigns (Code): runs custom JavaScript code
- Fetch Lists (HTTP Request): calls a.klaviyo.com
- Get Campaign Stats (HTTP Request): calls a.klaviyo.com (POST)
- Aggregate by Hour (Code): runs custom JavaScript code
- Format Email Report (Code): runs custom JavaScript code
- Gmail: uses Gmail
Services it uses
HTTP calls to: a.klaviyo.com
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (6)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - HTTP Request
n8n-nodes-base.httpRequest - Code
n8n-nodes-base.code - Gmail
n8n-nodes-base.gmail - Error Trigger
n8n-nodes-base.errorTrigger
From the author
How it works Every Monday at 8 AM, the workflow pulls all sent email campaigns from Klaviyo for the past 90 days It fetches open rate and click rate for each campaign, then groups results by audience segment and send hour Time slots with at least 3 campaigns…