Skip to main content

Documentation 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.

window.track(action, label) is defined in track.js and sends a fire-and-forget POST beacon to the Cloudflare Worker. If THEME.trackUrl is null (the default in a fresh fork), the function is a no-op — tracking is completely disabled and no network requests are made. Every user interaction with the map that is worth measuring fires a corresponding event via this function.

track.js source

The full implementation is intentionally minimal:
// Lightweight event tracker — sends fire-and-forget beacons to a Cloudflare Worker.
// Set THEME.trackUrl to the worker URL to enable, or leave null to disable.
(function () {
  var url = typeof THEME !== "undefined" && THEME.trackUrl;
  if (!url) return;

  // Skip tracking on localhost / local dev
  var h = location.hostname;
  if (h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0") return;

  window.track = function (action, label) {
    if (navigator.sendBeacon) {
      var blob = new Blob([JSON.stringify({ action: action, label: label })], { type: "application/json" });
      navigator.sendBeacon(url, blob);
    }
  };
})();
Key properties of this implementation:
  • Self-contained IIFE — sets up window.track exactly once at page load.
  • Graceful no-op — if THEME.trackUrl is falsy, the module returns immediately without defining window.track. All call sites in app.js check typeof track !== "undefined" before calling it, so no errors occur.
  • Localhost guard — events are never sent during local development (localhost, 127.0.0.1, 0.0.0.0), preventing test noise in the Analytics Engine dataset.
  • sendBeacon — uses the Beacon API so events are delivered even when the page is closing (e.g. “Get Directions” click that opens a new tab).

Event reference

The table below lists every action tracked by the map application.
ActionWhen it firesLabel value
viewPopup opened via map marker click or sidebar item clickRestaurant name
sidebar-viewSidebar list item scrolled into the visible viewportRestaurant name
directions-appleApple Maps directions link clicked in popupRestaurant name
directions-googleGoogle Maps directions link clicked in popupRestaurant name
websiteRestaurant website link clickedRestaurant name
phonePhone number link clickedRestaurant name
instagramInstagram profile link clickedRestaurant name
shareShare button clicked (copies link or opens share sheet)Restaurant name
upvoteLike/favorite button toggled onRestaurant name
un-upvoteLike/favorite button toggled offRestaurant name
deeplinkPage loaded with a URL hash (#restaurant-slug) that auto-opens a popupRestaurant name
filter-areaArea filter button clicked in the sidebar filter barArea name (e.g. "Downtown")
filter-tagDietary tag filter button clicked (vegetarian, gluten-free, etc.)Tag name
filter-hoursHours-based filter clicked (Open Now, Lunch, Dinner)Filter type string
tip-sSmall tip tier button clicked in the tip jar modal"tip-jar"
tip-mMedium tip tier button clicked in the tip jar modal"tip-jar"
tip-lLarge tip tier button clicked in the tip jar modal"tip-jar"
tip-shareShare button clicked inside the tip jar modal"tip-jar"
stats-viewStats page (/stats) loaded"stats"
The search action is also written to the Analytics Engine — it records the query string as the label. Search events are only accessible via the protected GET /?admin=true&token=X endpoint, not via the public stats GET endpoints.

Using tracking data

Once THEME.trackUrl is set and the Worker is deployed, tracking data flows into Cloudflare Analytics Engine and is immediately queryable through the Worker’s GET endpoints. Stats leaderboard (/stats)GET / returns the per-restaurant action breakdown. The stats page uses these counts to rank restaurants by engagement, computing a weighted score from views, direction clicks, shares, and upvotes. Trends chart (/stats)GET /?hourly=true returns time-series data bucketed by hour. The stats page renders this as an area chart showing total event volume over the event week. Supplying &start=YYYY-MM-DD&end=YYYY-MM-DD constrains the window to your exact event dates. Per-restaurant trendGET /?hourly=true&label=RestaurantName returns hourly totals for a single restaurant, used to render sparklines or per-restaurant trend charts. Concluded event — After the event ends, run ./snapshot-hourly.sh to write snapshots/hourly-events.json and snapshots/hourly-labels.json into the repo. The stats page loads these static files automatically once the event is marked concluded, so charts continue to work even after trackUrl is set back to null and the Worker stops receiving writes.
During local development, window.track is never defined (the localhost guard exits early), so you can click freely without polluting your Analytics Engine dataset.

Build docs developers (and LLMs) love