Google Apps Script

How to Build a Google Sheets Ecommerce Order Tracker with Apps Script to Safeguard Cash Flow

Step‑by‑step guide to create a Google Sheets‑based order tracker using Apps Script, covering deployment, permissions, cash‑flow checks and a practical checklist for small‑business owners.

You're ready to start selling, but you worry that a manual spreadsheet will miss payments, double‑count inventory, or hide cash‑flow gaps. The quickest, low‑cost solution is a Google Sheets ecommerce order tracker powered by Apps Script. It records orders, flags unpaid invoices, and sends you a daily cash‑flow summary—all without leaving the spreadsheet you already use.

What the tracker does (and what it doesn't)

In plain English, the script adds three core features to a standard product catalogue sheet:

  • Order capture: a web‑app form writes each new order to an "Orders" tab.
  • Payment status check: a time‑driven trigger flags rows where Paid? is blank and emails you a reminder.
  • Cash‑flow snapshot: a daily summary sheet shows total pending payments, expected cash‑in, and a simple risk indicator.

It does not replace a full accounting system, process refunds, or handle tax calculations. Think of it as a safety net for the first few weeks of sales.

Prerequisites – What you need before you start

  1. A Google account with access to Google Drive.
  2. A new Google Sheet with three tabs: Products, Orders, and CashFlow. Create column headers as shown in the example below.
  3. Basic familiarity with the Apps Script editor (just copy‑paste the code provided).
  4. Permission to send email from the account (required for the reminder feature).

If any of these items are missing, pause and set them up first – the script will fail silently otherwise.

Step‑by‑step setup

1. Build the spreadsheet structure

In the Products tab, add these columns (you can add more later):

  • SKU
  • Product Name
  • Price (USD)
  • Stock Qty

In the Orders tab, add:

  • Order ID (auto‑generated)
  • Date
  • SKU
  • Quantity
  • Total Price
  • Customer Email
  • Paid? (Yes/No)

In the CashFlow tab, reserve a few cells for the summary that the script will fill automatically (e.g., B2 = Pending Payments, B3 = Expected Cash‑In, B4 = Risk Level).

2. Add the Apps Script project

  1. Open the sheet, click Extensions → Apps Script.
  2. Delete any starter code and paste the script below. /** * Web‑app entry point – called from the order form. */ function doPost(e) { const ss = SpreadsheetApp.getActiveSpreadsheet(); const orders = ss.getSheetByName('Orders'); const data = JSON.parse(e.postData.contents); const newRow = [ Utilities.getUuid(), // Order ID new Date(), // Date data.sku, data.qty, data.qty * data.price, data.email, '' // Paid? left blank ]; orders.appendRow(newRow); return ContentService.createTextOutput(JSON.stringify({status:'ok'})) .setMimeType(ContentService.MimeType.JSON); } /** * Daily trigger – scans for unpaid orders and emails a summary. */ function dailyCashFlowCheck() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const orders = ss.getSheetByName('Orders'); const range = orders.getDataRange(); const values = range.getValues(); let pending = 0; let rows = []; for (let i = 1; i < values.length; i++) { // skip header const paid = values[i][6]; // Paid? column const amount = values[i][4]; // Total Price if (!paid) { pending += amount; rows.push(values[i]); } } // Write summary const cf = ss.getSheetByName('CashFlow'); cf.getRange('B2').setValue(pending); cf.getRange('B3').setValue('=SUM(Orders!E2:E)'); // total sales cf.getRange('B4').setValue(pending > 500 ? 'High' : 'Low'); // Email reminder if pending > $200 if (pending > 200) { const subject = '⚠️ Pending Payments Alert'; const body = `You have $${pending.toFixed(2)} in unpaid orders.\n\nDetails:\n` + rows.map(r=>`- ${r[0]} (${r[2]} x ${r[3]}) $${r[4].toFixed(2)}`).join('\n'); MailApp.sendEmail(Session.getActiveUser().getEmail(), subject, body); } }
  3. Save the project (e.g., OrderTracker).

3. Deploy as a web app

  1. Click Deploy → New deployment**.
  2. Select Web app**.
  3. Set Execute as** to Me (your account) and Who has access** to Anyone (or Anyone with the link if you prefer tighter control).
  4. Click **Deploy**, copy the URL – you will use it as the form action.

4. Create a simple HTML order form (optional)

If you need a quick front‑end, embed this snippet on any website or a Google Site. Replace YOUR_WEB_APP_URL with the URL from step 3.

<form id="orderForm"> SKU: <input name="sku" required><br> Quantity: <input type="number" name="qty" min="1" required><br> Price: <input type="number" step="0.01" name="price" required><br> Email: <input type="email" name="email" required><br> <button type="submit">Place Order</button> </form> <script> const form = document.getElementById('orderForm'); form.addEventListener('submit', e=>{ e.preventDefault(); const data = Object.fromEntries(new FormData(form)); fetch('YOUR_WEB_APP_URL', { method:'POST', body: JSON.stringify(data) }).then(r=>r.json()).then(r=>alert('Order recorded')); }); </script>

5. Set up the daily trigger

  1. In Apps Script, click the clock icon (Triggers).
  2. Add a trigger for dailyCashFlowCheck, choose Time‑driven → Day timer → 8 am (adjust to your workday).
  3. Authorize the script when prompted – you will see a permissions screen listing View and manage your spreadsheets and Send email as you.

Common mistakes and how to fix them

  • Missing email permission: The script will fail silently on the reminder step. Re‑run the trigger setup and grant MailApp access.
  • Incorrect column indexes: If you added extra columns, update the numeric indexes in the script (e.g., values[i][6] for Paid?).
  • Trigger not firing: Check the Executions log for errors; often the cause is a changed sheet name.
  • Web‑app URL exposed publicly: If you need tighter security, restrict access to specific email addresses and add a simple token check inside doPost.

Setup checklist – before you go live

  1. Spreadsheet tabs and column headers match the script.
  2. Apps Script project saved and deployed as a web app.
  3. Daily trigger created and confirmed in the Triggers dashboard.
  4. Email permissions granted; test by running dailyCashFlowCheck manually.
  5. Place a test order via the form – verify it appears in Orders and that the CashFlow summary updates.
  6. Check the daily email (if pending > $200) reaches your inbox.
  7. Document the URL and share it only with trusted staff.

When to consider professional help

If you anticipate any of the following, it may be worth hiring a developer:

  • Multiple sales channels (e.g., Shopify + WooCommerce) that need consolidated reporting.
  • Complex tax or multi‑currency calculations.
  • Integration with a third‑party accounting package (Xero, QuickBooks).

A specialist can extend the script, add secure OAuth flows, or move the logic to a Cloud Function for higher volume.

Conclusion

Building a Google Sheets ecommerce order tracker with Apps Script gives you immediate visibility into pending payments and cash‑flow risk without a large upfront investment. Follow the steps, run the checklist, and you’ll have a lightweight safety net that scales until your sales outgrow a spreadsheet.

Ready to jump ahead? View the Apps Script ecommerce source‑code package. Need help deploying or customizing the workflow? Ask us at Nextpath Solutions.