# Marketing Engine — Starter The smallest possible version. ~150 lines of Apps Script. One Sheet. Two menu items: build a dashboard, generate a weekly summary. You'll extend this in the hour. ## What it does - Imports the marketing dataset (12 weeks × 5 channels × 4 metrics) - A "Build basic dashboard" button that creates a fresh Dashboard tab with one chart (total sessions per week) - A "Generate weekly summary" button that asks Gemini to write a 4-6 bullet update, dropped on a Summary tab - A custom `=ASK()` function you can use in any cell — try it on a range of data ## What it doesn't do (yet) - No multiple charts or per-channel views - No anomaly detection - No Gmail draft of the email - No Slides export - No brand voice - No scheduled trigger Each of those is an upgrade you can add. ## Setup (5 minutes) ### 1. Get a Gemini API key - Go to **https://aistudio.google.com/apikey** - Click "Create API key" - Copy the key ### 2. Create a Sheet and import the data - New Google Sheet → name it "Marketing engine" - File → Import → Upload → drag in `marketing_metrics.csv` (in the `data/` folder) - Choose **Replace current sheet**, separator type **Detect automatically** - Right-click the imported tab → Rename → call it `Data` ### 3. Open Apps Script and paste the code - Extensions → Apps Script - Delete the default `function myFunction() {}` placeholder - Paste the contents of `Code.gs` from this folder ### 4. Save the API key as a Script Property - In Apps Script: Project Settings (gear icon) → Script Properties → Add script property - Name: `GEMINI_API_KEY` - Value: paste your key - Save ### 5. Reload the Sheet - Close and reopen the Sheet (or hit refresh) - A new "Marketing engine" menu appears next to Help ### 6. Try it - Marketing engine → **Build basic dashboard**. First run will prompt for permissions — let it through. A Dashboard tab appears with a chart. - Marketing engine → **Generate weekly summary**. A Summary tab appears with a 4-6 bullet update. - Try `=ASK("classify the trend of this metric in one word", D2:D13)` in any free cell. ## Where to take it Open `HACKATHON_BRIEF.md` for the full upgrade ladder. Pick a level and go. A few starter ideas: - **More charts.** The dashboard has one. Add a stacked chart by channel. Add sparklines per channel using `=SPARKLINE()`. - **Smarter summary.** Pass only the latest two weeks instead of all 12 — does the AI find more specific takeaways? - **Anomaly detection.** Compute a rolling mean and standard deviation per channel. Flag any week where a metric is more than 2σ from its rolling mean. Then ask AI to explain what the flagged week looks like. - **Email draft.** After generating a summary, write it into a Gmail draft using `GmailApp.createDraft(to, subject, body)` — a single call. - **Slides export.** Use `SlidesApp.create()` to spin up a deck from the Dashboard's charts and the Summary text. - **Scheduled trigger.** Triggers (clock icon in Apps Script) → Add trigger → run `generateWeeklySummary` on a weekly time-based trigger. The reference build shows what each of these looks like in full. Steal what's useful.