Shopify & GA4 Daily Sales & Performance Reporting Automation: n8n & Activepieces
An automated daily reporting pipeline built on self-hosted n8n and Activepieces that extracts daily sales metrics from Shopify Admin API, pulls traffic and conversion data from GA4, updates Google Sheets, and dispatches executive morning email digests.
Core Code Architecture:
n8n Dual-Source Aggregator & Daily Sales Metrics Code Node // n8n Code Node: Dual-Source Aggregator & Daily Sales Metrics
const dateContext = $("Compute Reporting Date Window").first().json;
const shopifyRaw = $("Shopify: Get Many Orders").first().json;
const ga4Raw = $("Google Analytics 4: Get Daily Report").first().json;
// 1. Process Shopify Orders (Financial Source of Truth)
const orders = Array.isArray(shopifyRaw) ? shopifyRaw : (shopifyRaw.orders || []);
let grossSales = 0, totalDiscounts = 0, totalTax = 0, totalRefunds = 0;
const skuVolume = {};
orders.forEach(ord => {
grossSales += parseFloat(ord.subtotal_price || ord.total_price || 0);
totalDiscounts += parseFloat(ord.total_discounts || 0);
totalTax += parseFloat(ord.total_tax || 0);
(ord.refunds || []).forEach(ref => {
(ref.transactions || []).forEach(t => totalRefunds += parseFloat(t.amount || 0));
});
(ord.line_items || []).forEach(item => {
const sku = item.sku || item.title || "Product";
skuVolume[sku] = (skuVolume[sku] || 0) + (item.quantity || 1);
});
});
const orderCount = orders.length;
const netSales = grossSales - totalDiscounts - totalRefunds;
const aov = orderCount > 0 ? (netSales / orderCount) : 0;
// Sort top SKUs
const topSkus = Object.entries(skuVolume)
.sort((a, b) => b[1] - a[1])
.slice(0, 2)
.map(([name, qty]) => `${name} (${qty} sold)`);
// 2. Process GA4 Telemetry & Attribution
let ga4Revenue = 0, ga4Sessions = 0, ga4Transactions = 0;
if (ga4Raw.rows && ga4Raw.rows.length > 0) {
ga4Revenue = ga4Raw.rows.reduce((sum, r) => sum + parseFloat(r.metricValues?.[0]?.value || 0), 0);
ga4Sessions = ga4Raw.rows.reduce((sum, r) => sum + parseInt(r.metricValues?.[1]?.value || 0), 0);
ga4Transactions = ga4Raw.rows.reduce((sum, r) => sum + parseInt(r.metricValues?.[2]?.value || 0), 0);
}
const conversionRate = ga4Sessions > 0 ? ((orderCount / ga4Sessions) * 100).toFixed(2) + "%" : "0.00%";
return [{
json: {
report_date: dateContext.report_date || new Date().toISOString().split('T')[0],
shopify_orders: orderCount,
shopify_gross: "$" + grossSales.toFixed(2),
shopify_discounts: "$" + totalDiscounts.toFixed(2),
shopify_refunds: "$" + totalRefunds.toFixed(2),
shopify_net: "$" + netSales.toFixed(2),
shopify_aov: "$" + aov.toFixed(2),
ga4_revenue: "$" + ga4Revenue.toFixed(2),
ga4_sessions: ga4Sessions,
ecommerce_cr: conversionRate,
top_sku_1: topSkus[0] || "N/A",
top_sku_2: topSkus[1] || "N/A",
logged_at: new Date().toISOString()
}
}];
GTM Template & Configuration Screenshots:
Verified Sandbox Environment
The Manual Morning Reporting Bottleneck Solved
E-commerce managers and marketing teams frequently lose 30 to 45 minutes every morning logging into disparate dashboards (Shopify Admin and Google Analytics 4), pulling raw CSV exports, manually calculating net sales and AOV in spreadsheets, and drafting executive update emails. This automation eliminates that manual grind completely.
- Zero Manual Morning Effort: 100% automated workflow executing at 08:00 AM UTC every single day
- Dual-Source Consolidation: Merges Shopify financial data (gross/net sales, discounts, refunds, top SKUs) with GA4 traffic telemetry (sessions, conversion rates)
- Automated Google Sheets Ledger: Appends an audit-ready row to the tracking Google Sheet (Daily_Sales) automatically
- Executive HTML Morning Email: Delivers a clean, formatted executive summary digest directly to stakeholders' inboxes
- Dual-Platform Flexibility: Full operational blueprints provided for both self-hosted n8n and Activepieces
n8n Daily Sales Reporting Pipeline Architecture
Fires daily on a cron trigger, computes the yesterday reporting date window, queries Shopify Admin API for orders and GA4 Data API for traffic metrics in parallel, aggregates KPIs in a custom JavaScript code node, appends the structured row to Google Sheets, and sends an executive HTML email digest via Gmail SMTP.
Activepieces Daily Reporting Flow Architecture
Built as a streamlined 5-step flow on Activepieces: triggers daily on schedule, calculates the reporting date window via TypeScript/JavaScript code piece, ingests Shopify orders, logs the daily row into Google Sheets, and dispatches the HTML morning report email to the team.
1-Click Importable Blueprints (n8n & Activepieces)
All workflows are provided as complete, production-ready JSON blueprints configured with node parameters, data mappings, Google Sheets schemas, and HTML email templates.
- shopify-ga4-daily-sales-n8n-workflow.json: Production n8n workflow blueprint with official Shopify and GA4 nodes, Code Aggregator, Google Sheets logging, and Gmail SMTP digest (Available at /downloads/shopify-ga4-daily-sales-n8n-workflow.json)
- shopify-ga4-daily-sales-activepieces-flow.json: Complete Activepieces flow blueprint with Schedule Trigger, Code piece, Shopify Admin API step, Google Sheets piece, and Gmail piece (Available at /downloads/shopify-ga4-daily-sales-activepieces-flow.json)