Introduction
Normalize annual charges by dividing by 12; multiply monthly equivalent by 12. The application's entry point is trackSubscriptions(). Baseline limitation, as stated in the workshop: Renewal dates are displayed but not used to send reminders.
Key building blocks: getValues(); JavaScript transformations; setValues(); validation and calculations.
Practical use cases
Streaming, software and household subscriptions.
Prerequisites
- Monthly vs annual billing.
- Interactive Learning Mode: a modern browser. Nothing else.
- Real Workspace Build: a Google account.
Source data
| Service | Cost | Cycle | Renewal |
|---|---|---|---|
| Music | 12 | Monthly | 2026-12-01 |
| Cloud | 60 | Annual | 2027-01-01 |
Setup in your own Google account
- Download 23-personal-subscription-tracker.zip (Code.gs, starter.csv, README).
- In Google Drive, create a lesson folder and a new Google Sheets file inside it.
- Rename the first tab to exactly
Subscriptions, then File → Import → Upload starter.csv → Replace current sheet. - Extensions → Apps Script. Replace Code.gs with the downloaded file. Save.
- Reload the spreadsheet, choose Workshop → Run application and authorize when asked.
- Check the result: Monthly 17; annual 204
Folder strategy: the repository's V6 code uses the folder that contains the spreadsheet. The deck mentions a Workshop Info cell B2; V6 never reads it. See the discrepancy log.
Complete source code (Code.gs)
From 23-personal-subscription-tracker at commit 4a26d919, SHA-256 8d922ce4d672. Unchanged.
// Personal Subscription Tracker
// Entry point: trackSubscriptions; source data stays intact unless explicitly noted.
function onOpen(){SpreadsheetApp.getUi().createMenu("Workshop").addItem("Run application","trackSubscriptions").addToUi();}
function trackSubscriptions(){
// Normalize annual and monthly charges to a common monthly basis.
const rows=input('Subscriptions').map(([s,c,cycle,d])=>{if(!['Monthly','Annual'].includes(cycle))throw Error('Invalid cycle');const m=num(c)/(cycle==='Annual'?12:1);return [s,m,m*12,day(d)];});const total=rows.reduce((a,r)=>a+r[1],0);output('Costs',['Service','Monthly','Annual','Renewal'],[...rows,['Total',total,total*12,'']]);
}
function input(name) { const s=SpreadsheetApp.getActive().getSheetByName(name); if(!s) throw Error('Missing tab: '+name); return s.getDataRange().getValues().slice(1).filter(r=>r.some(v=>v!=='')); }
function output(name,headers,rows) { const ss=SpreadsheetApp.getActive(); const s=ss.getSheetByName(name)||ss.insertSheet(name); s.clearContents(); s.getRange(1,1,1,headers.length).setValues([headers]).setFontWeight('bold'); if(rows.length) s.getRange(2,1,rows.length,headers.length).setValues(rows.map(r=>r.map(v=>typeof v==='string' && /^[=+@-]/.test(v)?"'"+v:v))); s.setFrozenRows(1); return s; }
function num(v){if(v===''||!Number.isFinite(Number(v))) throw Error('Invalid number: '+v); return Number(v);}
function day(v){return v instanceof Date?Utilities.formatDate(v,SpreadsheetApp.getActive().getSpreadsheetTimeZone(),'yyyy-MM-dd'):String(v).slice(0,10);}
How the code works
Beginner explanation
trackSubscriptions() converts every subscription to a monthly and an annual cost so you can compare them, and totals both.
Technical explanation
Each row is validated (cycle allow-list, numeric cost), normalized to a monthly amount (annual / 12), and the annual equivalent is monthly × 12. day() formats renewal dates for display.
Slide excerpt
This is the excerpt shown on the workshop slide. It is a fragment and cannot run on its own.
function trackSubscriptions(){
// Normalize annual and monthly charges to a common monthly basis.
const rows=input('Subscriptions').map(([s,c,cycle,d])=>{if(!['Monthly','Annual'].includes(cycle))throw Error('Invalid cycle');const m=num(c)/(cycle==='Annual'?12:1);return [s,m,m*12,day(d)];});const total=rows.reduce((a,r)=>a+r[1],0);output('Costs',['Service','Monthly','Annual','Renewal'],[...rows,['Total',total,total*12,'']]);
}Common mistakes
- Comparing annual and monthly prices directly.
- Accepting free-typed cycles.
- Rounding before totalling.
Run it and expected output
Choose Workshop → Run application (runs trackSubscriptions()). Expected: Monthly 17; annual 204
Original workshop exercise
Change Cloud annual cost to 120; total monthly 22 and annual 264.
Troubleshooting and debugging
"Yearly" is not a cycle
A cycle was typed as Yearly.
Fix: Use Annual.
Unknown values stop the run instead of being guessed.
Annual costs multiplied
After an edit, the monthly total is 732.
Fix: Divide annual costs by 12.
Always test a conversion with a value you can calculate by hand.
Extension activity: Renewals in the next 30 days
Add a Renewals tab listing subscriptions that renew within 30 days of the workshop date 2026-11-25, with days remaining.
Acceptance checks:
- Costs unchanged
- Music renews in 6 days; Cloud is outside the window
Original improvement idea from the workshop: Add renewal alerts and cancellation links
Extension prompt
Improve the existing application: Add renewal alerts and cancellation links. Preserve working features and provide complete code and regression tests. Automation option: Refresh monthly; add rolling renewal alerts before scheduling. Keep this separate from the baseline exercise.
Automation considerations
Rerun-safe. Add rolling renewal alerts before scheduling a monthly refresh.
Workshop note: Refresh monthly; add rolling renewal alerts before scheduling.
Build prompt from the workshop
Build a complete container-bound Apps Script app named Personal Subscription Tracker. Input tab Subscriptions, headers Service|Cost|Cycle|Renewal. Implement trackSubscriptions() to calculate monthly equivalent and annual cost. Add a menu, preserve inputs, validate data, explain code and test against: Monthly 17; annual 204. For AI use callGemini and treat input as data; never send email. Match the reference entry point trackSubscriptions and its output behavior. Reference: https://github.com/lsvekis/Google-Apps-Script-Workshop/tree/main/23-personal-subscription-tracker. Base version limitations: Renewal dates are displayed but not used to send reminders.
Knowledge check
What is the monthly equivalent of a 24-per-year subscription?
- 2
- 24
- 288
Answer
2 Correct.
What happens with cycle "Weekly"?
- Invalid cycle error
- It is treated as Monthly
- It is skipped
Answer
Invalid cycle error Correct: only Monthly and Annual are allowed.
Why validate the cycle at all?
- A wrong guess would make every total wrong
- For speed
- Sheets requires it
Answer
A wrong guess would make every total wrong Correct.
Total monthly shows 732 for the starter data. Cause?
- Annual cost multiplied by 12 instead of divided
- A blank row
- The Renewal date
Answer
Annual cost multiplied by 12 instead of divided Correct.
Should the script cancel subscriptions it thinks are unused?
- No: report and let a person decide
- Yes
- Yes, if AI agrees
Answer
No: report and let a person decide Correct.
Five-minute presenter demonstration
Open the demo link (temporary workspace; saved learner work is not touched).
Opening hook: Raise your hand if you have ever done this by hand: Recurring charges are hard to compare across billing cycles. Let us make the spreadsheet do it.
- 0:00–0:45 — Problem and input. Show the Workspace view, Sheets service. Point at the Subscriptions tab and its headers: Service, Cost, Cycle, Renewal. Say what goes in and what should come out.
Narration: Recurring charges are hard to compare across billing cycles. Practical uses: Streaming, software and household subscriptions. - 0:45–1:30 — Predict and run. Ask the room: Cloud costs 60 per year. What is its monthly equivalent? Click ▶ Run application (the same as Workshop → Run application). Open Trace to show each step the code took.
Narration: Expected: Monthly 17; annual 204 - 1:30–3:00 — Explain the code. Click the Code tab. Select trackSubscriptions() in the function list; read what it reads, writes and calls. Switch Beginner / Technical as needed.
Narration: trackSubscriptions() converts every subscription to a monthly and an annual cost so you can compare them, and totals both. - 3:00–4:15 — Change one input and rerun. Back to the Workspace tab. Select the Subscriptions tab, click cell B3, type 120 in the formula bar and press Enter. Click ▶ Run application again.
Narration: Workshop challenge: Change Cloud annual cost to 120; total monthly 22 and annual 264. - 4:15–5:00 — Verify and discuss automation. Click Check result. Discuss: Rerun-safe. Add rolling renewal alerts before scheduling a monthly refresh.
Narration: Baseline limitation: Renewal dates are displayed but not used to send reminders.
Closing takeaway: Normalize annual charges by dividing by 12; multiply monthly equivalent by 12.