Shopify Order Data Aggregator for Sales Reporting - n8n Workflow

Use this robust n8n workflow to reliably fetch all Shopify orders, overcoming the 250-item API limit via looping, and summarize sales data by SKU into Google Sheets. Download the n8n templates today.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

E-commerce Analysts needing reliable, automated sales reports.
Shopify Merchants who frequently hit API limits when querying large datasets.
Data Engineers looking for sophisticated n8n templates for handling API pagination.
Users seeking to implement complex logic using a custom code n8n node for data aggregation.

Overview

Extracting large datasets from services like Shopify can be challenging due to API pagination limits (typically 250 records per request). This specialized n8n workflow solves this problem by implementing a sophisticated looping mechanism using the n8n trigger, If, and GraphQL nodes. It reliably pulls all orders placed within the last 30 days, regardless of the volume, and aggregates the sales data (quantity and revenue) by product SKU.

After all data is collected across multiple pages, a custom JavaScript n8n node cleans and summarizes the information before the final results are automatically logged into a Google Sheet. This makes the entire process of monthly or weekly sales reporting effortless, demonstrating the powerful capabilities of an automated n8n solution.

How it Works

This powerful n8n workflow starts with a scheduled n8n trigger:


  1. Scheduled Execution: The automation is initiated by the Schedule n8n trigger at a specific time (configured to run daily at 8:43 AM in this template).

  2. Define Search Window: A Set n8n node (searchPeriod) dynamically calculates the startDay (30 days ago) and endDay (today) to define the specific window for the Shopify order extraction.

  3. Fetch Orders (Loop Start): The GraphQL n8n node (getOrderDoLoop) makes the initial call to the Shopify API, requesting the maximum limit of 250 orders, filtered by the date range.

  4. Pagination Check: The If n8n node checks the API response for pageInfo.hasNextPage.

  5. Loop Continuation: If hasNextPage is true, the flow loops back to the getOrderDoLoop n8n node, passing the endCursor to fetch the next 250 results. This effective use of the n8n trigger and logic ensures full dataset retrieval.

  6. Data Aggregation: Once hasNextPage is false, the workflow exits the loop and passes execution to the Code n8n node (groupItemListbyVendor). This custom n8n node iterates through all previous executions of the getOrderDoLoop node to gather all batches of orders, flattens the complex line item structure, and groups the resulting data by SKU, calculating total sales and total quantity sold.

  7. Final Reporting: The summarized SKU data is finally appended to the configured Google Sheets spreadsheet using the Google Sheets n8n node, concluding the n8n workflow.

Installation Guide

To use this reliable n8n workflow, follow these steps:


  1. Import: Import this n8n templates JSON into your n8n instance.

  2. Shopify Credential Setup: This n8n workflow requires a custom HTTP Header Authentication credential for Shopify, containing your Store URL and Admin API Access Token. Configure the credential for the getOrderDoLoop GraphQL n8n node.

Note:* Ensure your Shopify GraphQL endpoint is correctly set (e.g., https://your-store.myshopify.com/admin/api/2025-01/graphql.json).

  1. Google Sheets Credential Setup: Set up your Google Sheets OAuth2 API credentials and connect them to the Google Sheets n8n node (Google Sheets).

  2. Sheet Configuration: Configure the Google Sheets n8n node with the correct Document ID and Sheet Name where the sales data should be appended.

  3. Activate: Save and activate the n8n workflow. The scheduled n8n trigger will handle execution.

Node Details

Schedule Trigger (n8n trigger): The entry point for the n8n workflow. Triggers the execution automatically based on a predefined schedule (e.g., daily).
Set (searchPeriod n8n node): Defines the date range for the Shopify query, calculating the start day (30 days prior) and end day using n8n expressions.
GraphQL (getOrderDoLoop n8n node): Interfaces with the Shopify Admin API. Key configuration uses dynamic expressions to insert the endCursor for pagination and date filtering from the searchPeriod n8n node output.
If (is hasNextPage = true n8n node): Controls the pagination loop. Checks the data.orders.pageInfo.hasNextPage boolean. If true, the n8n node directs flow back to the GraphQL node.
Code (groupItemListbyVendor n8n node): The crucial customization point. This n8n node uses JavaScript to iterate over all data outputs generated by the looping GraphQL node, consolidates the line items, and groups the final sales data by SKU before outputting the summary.
Google Sheets (n8n node): The final action. Appends the structured, aggregated SKU sales summary data into the target Google Sheet document.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

A software developer obsessed with automation, systems, and webhooks. I launched Strategiflows to help businesses scale smarter, not harder. What started as a few clever workflows turned into a multi-million dollar success — all powered by automation.

Featured*