The tracking system records per-restaurant engagement events — popup views, directions clicks, share button taps, and upvotes — and surfaces them on theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/samgutentag/sbburgerweek/llms.txt
Use this file to discover all available pages before exploring further.
/stats leaderboard dashboard. It uses a Cloudflare Worker that writes events to Analytics Engine. The free tier covers 100,000 writes per day with 90-day data retention, which is more than enough for a week-long food event.
How tracking works
track.js is a lightweight, self-contained script loaded on every page. On load it reads THEME.trackUrl from config.js. If the URL is set, it defines window.track(action, label) as a function that serialises the event as JSON and fires it to the Worker via navigator.sendBeacon. If trackUrl is null, the entire setup is skipped — window.track is never defined and all call sites in app.js are silent no-ops.
/stats page and the snapshot workflow query the Worker’s GET endpoints to retrieve aggregated counts.
Setup
Install Wrangler and log in
wrangler login opens a browser window to authenticate with your Cloudflare account.Create an Analytics Engine dataset
In the Cloudflare dashboard, go to Workers & Pages → Analytics Engine → Create a dataset. Name it something descriptive for your event (e.g.
sbburritoweek). Note the dataset name — you’ll need it for wrangler.toml.Get your Cloudflare Account ID
On the Cloudflare dashboard home page, your Account ID is displayed in the right sidebar. It’s also visible in the URL:
dash.cloudflare.com/<ACCOUNT_ID>/.... Copy it.Configure wrangler.toml
Edit Replace
workers/track/wrangler.toml with your account ID and dataset name:YOUR_CLOUDFLARE_ACCOUNT_ID with the ID you copied in the previous step, and update the dataset name to match what you created. You can remove the RUM_SITE_TAG var if you don’t plan to use Cloudflare RUM (Browser Insights).Create an API Token
In the Cloudflare dashboard, go to My Profile (top-right avatar) → API Tokens → Create Token. Select Custom token and grant these permissions:
- Account → Analytics Engine → Read
- Account → Workers Scripts → Edit
Add Worker secrets
wrangler.toml or your repo.Update the event start date
Open Change the date to your event’s start date in UTC. If you’ve already set
workers/track/index.js and find all SQL queries containing a line like:eventStartDate in config.js, running python3 apply-theme.py updates this automatically.Enable event writes in index.js
In
workers/track/index.js, locate the POST handler. If there is an early return statement near the top of the handler (added when winding down a previous event to disable writes), remove it and uncomment the writeDataPoint call below it so that incoming events are actually stored.What gets tracked
Every meaningful interaction fires awindow.track(action, label) call. Here’s the full event table:
| Action | When fired | Label |
|---|---|---|
view | Restaurant popup opened (map or sidebar click) | Restaurant name |
sidebar-view | Sidebar item scrolled into view | Restaurant name |
directions-apple | Apple Maps link clicked | Restaurant name |
directions-google | Google Maps link clicked | Restaurant name |
website | Website link clicked | Restaurant name |
phone | Phone link tapped | Restaurant name |
instagram | Instagram link clicked | Restaurant name |
share | Share button clicked | Restaurant name |
upvote / un-upvote | Like button toggled | Restaurant name |
deeplink | Arrived via URL hash (#slug) | Restaurant name |
filter-area | Area filter button clicked | Area name |
filter-tag | Dietary tag filter clicked | Tag name |
filter-hours | Hours filter clicked | Filter type |
tip-s / tip-m / tip-l | Tip jar tier clicked | "tip-jar" |
tip-share | Tip jar share button clicked | "tip-jar" |
stats-view | Stats page loaded | "stats" |
Enabling and disabling writes
The Worker’s POST handler has an intentional on/off mechanism: an earlyreturn statement that short-circuits writes. Use this pattern when winding down an event so the Worker stays deployed (to serve the stats page) but stops accepting new events.
Before your event — remove the early return and ensure writeDataPoint is active.
After your event — add back the early return and comment out writeDataPoint, then redeploy: