Block markup reference
This page shows what each interactive block puts in the mailed HTML and how a reader's answer reaches MailInApp. It's written for developers and for anyone who exports HTML to send through another platform. Each block's own page describes what readers see and what you get back. The tiers themselves are explained in How fallbacks work.
The samples are trimmed: real output carries more inline styles, a dark-mode class or two, and your theme's colours. Every link points at the recipient's signed live-view token (/v/[token]), which identifies the email and, for a personalized send, the recipient.
How answers are recorded
Two paths lead to the same recording endpoint and produce the same event, so results never depend on where a reader answered.
- Confirm links. A one-tap answer is an
<a href>into/v/[token]/actwith the block, the action and the value in the query. The page it opens asks the reader to confirm, and the confirming form post records the answer. A bare GET records nothing, so link scanners and inbox security tools that prefetch every link can't vote. See Scanner-proof interaction recording. - Form posts. A block with typed or several answers mails a
<form method="post">that posts to/api/interactionsasapplication/x-www-form-urlencoded. Gmail on the web and the Outlook apps for iOS and Android send it from the email. Every such form also carries an always-visible Answer on the web link to the same block on the live view, where it's an ordinary web form.
A recipient's answer is stored once per email, block and recipient, under a document id built from the three, so a repeated tap or a retried page load is a no-op. Answers from an exported email with no recipient token have no person to key on, so they're rate-limited per IP, per campaign and per minute instead.
Feedback blocks
Poll
Each option is a confirm link styled as a chip. It's always visible, in every email app.
<div id="em-poll-1" style="margin:12px 0;background-color:transparent">
<p style="margin:0 0 10px;font-weight:600;font-size:16px;color:#111827">Which do you prefer?</p>
<div>
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=poll-1&blockType=poll&action=vote&option=Option+A&optionId=poll-option-2"
style="display:inline-block;margin:0 6px 6px 0;padding:8px 14px;border:1px solid #d1d5db;border-radius:6px;background-color:#ffffff;color:#111827;font-size:14px;text-decoration:none">
Option A
</a>
<a href="...option=Option+B&optionId=poll-option-3" ...>
Option B
</a>
</div>
</div>
With Allow several answers, the poll mails a form of checkboxes posting one optionId per ticked option (stored as parallel option and optionId lists), plus the Answer on the web link. An Other option is a link to the poll on the live view, where the reader types their answer. A shuffled poll's order is seeded by the recipient's token, so it's the same on every open. The Live results image is an <img> from /api/results-image, signed per poll option, never per recipient.
Rating
The default Stars display mails one confirm link per star, highest first, in a right-to-left row. Each link holds an outline star and a filled one; a :hover rule fills the stars up to the pointer where the app supports it, and the outline stars show everywhere else. The star pictures come from /api/rating-icon.
<div id="em-rating-1" style="margin:12px 0;background-color:transparent">
<p style="margin:0 0 10px;font-weight:600;font-size:16px;color:#111827">How did we do?</p>
<div dir="rtl" style="direction:rtl;text-align:left;line-height:0">
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=rating-1&blockType=rating&action=rate&rating=5"
class="em-rating-1-s" aria-label="5 out of 5 stars" style="display:inline-block;padding:6px;line-height:0">
<img src="https://mailinapp.com/api/rating-icon?f=0&c=f59e0b&s=32" alt="5★" width="32" height="32" class="em-rating-1-o">
<!--[if !mso]><!-->
<img src="https://mailinapp.com/api/rating-icon?f=1&c=f59e0b&s=32" alt="" width="32" height="32" class="em-rating-1-f" style="display:none">
<!--<![endif]-->
</a>
<!-- …one link per star, down to rating=1 -->
</div>
</div>
Every other display (emoji faces, thumbs, a numbered scale, NPS and the classic star chips) is a row of confirm links carrying rating=<n>. When the score is at or under the block's follow-up threshold, the confirm page continues to /v/[token]/followup.
Quiz
The quiz mails a form with one radio group per question, posting q0, q1… (the question's authored position) to /api/interactions, plus the Answer on the web link.
<div style="margin:12px 0;background-color:transparent">
<p style="margin:0 0 10px;font-weight:700;font-size:18px;color:#111827">
Test your knowledge!
</p>
<!-- <form method="post" action="https://mailinapp.com/api/interactions">:
one radio group per question plus a "See my score" button -->
<p style="margin:8px 0 0;font-size:13px;text-align:center">
<a href="https://mailinapp.com/v/eyJhbGci...#em-quiz-1">Answer on the web</a>
</p>
</div>
Scoring happens on the server, against the answer key in the stored email; a score posted by a client is never trusted. The event's value is {answers, score, total, bucket} for a scored quiz and {answers, outcome, outcomeTitle} for a personality quiz. With Show right or wrong right away, each answer's label carries a hidden note that a :checked rule reveals, so the answer key is in the mailed HTML. A cover screen keeps the questions behind a :target anchor on the live view.
Form
A single-page form mails every field in one <form> posting to /api/interactions, plus the Answer on the web link.
<div id="em-form-1" style="margin:12px 0;background-color:transparent">
<!-- <form method="post" action="https://mailinapp.com/api/interactions">:
every field plus one Submit button -->
<p style="margin:8px 0 0;font-size:13px;text-align:center">
<a href="https://mailinapp.com/v/eyJhbGci...#em-form-1">Answer on the web</a>
</p>
</div>
A multi-page form mails no fields, only a button-styled link with its Start button label into the survey wizard at /v/[token]/form/[blockId]. Each page there saves a draft (a form-page action that touches no results or webhooks), and the last page's submit turns the draft into the response. With Steps in the email, the pages mail as one radio per page before the form and :checked rules that show one page at a time; apps without those rules show every page. A file field links to the live view, since a file can only be added from a browser. Conditional questions all show in the mailed form; the server drops the answers to questions that the reader's earlier answers hide.
The server checks every answer against the form in the stored email before writing anything. A browser that sent an invalid answer is sent back to /v/[token]?invalid=<fieldId>&why=<problem>, and a JSON caller gets a 400 invalid-answer.
Shop and reviews blocks
Links in these blocks go through /v/[token]/click, which records the click and redirects to the destination. Replays of the same signed link within five minutes count once.
Countdown
The countdown is one <img> from /api/countdown. Its URL is signed over the end and the colour, and each fetch draws a fresh 60-frame GIF from the time left, one second a frame, that then holds on its last frame. Identical signed requests share a render for up to ten seconds. The alt text carries the time left in words for screen readers and for apps that load pictures late.
<div style="margin:12px 0">
<p style="margin:0 0 6px;font-size:16px;font-weight:700;color:#111827">Offer ends in</p>
<img src="https://mailinapp.com/api/countdown?t=1753401600000&c=111827&s=9f2a..."
width="207" height="34" alt="Offer ends in 2d 4h"
style="display:block;max-width:100%;height:auto">
</div>
An end per contact (A time after it's sent or A date in the contact's data) is worked out at send time. It's stored on the recipient's row as countdown_ends_<blockId> and in their live-view token, so every open shows the same end. A countdown already past its end at render time mails its ended message as text instead of the image. Clicks carry the recipient's end, so the countdown's rollup counts each click before or after that recipient's own deadline.
Product
With MailInApp checkout, Buy now is a confirm link into /v/[token]/act?action=buy. The confirm page re-reads the product from the stored email and its POST creates the Stripe Checkout Session through /api/checkout; a bare GET creates nothing. Price, name and stock always come from the server's copy. An order becomes paid only on Stripe's signed webhook, which re-checks the stock in a transaction and refunds a payment that would oversell. With an Inventory set, the card carries a stock badge from /api/product-status, redrawn from the paid-unit count at most once a minute.
<div id="em-product-1" style="margin:12px 0;padding:16px;border:1px solid #e5e7eb;border-radius:8px;background-color:#ffffff">
<p style="margin:0 0 4px;font-weight:600;font-size:16px;color:#111827">Limited edition tote bag</p>
<p class="pd-price" style="margin:0 0 10px;font-weight:700;font-size:18px">$29.00</p>
<img src="https://mailinapp.com/api/product-status?p=proj123&b=product-1&s=..."
width="180" height="30" alt="" style="display:block;margin-bottom:8px">
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=product-1&blockType=product&action=buy"
style="display:inline-block;padding:10px 20px;background-color:#4f46e5;color:#ffffff;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600">
Buy now
</a>
</div>
With Link to external store checkout, Buy now is a click link to the product page (with ?variant= for an imported Shopify variant), or to a per-recipient discount link minted at send time when Per-product discount is on.
Variants mail one hidden radio per option value before the price, a row of chips (.pv-opts, <label for> the radios) and one panel per variant (.pv-panels) with its price and buy link. Rules of the form #<id>-a<i>:checked:not(:disabled) ~ … show the chips and the picked variant's panel, and hide .pd-price and .pv-list. Where those rules don't run, the price and .pv-list show: one link per variant, each buying that variant (&variant=<variantId>). More pictures use the image gallery's thumbnails, with small linked pictures as their fallback. Save for later is a confirm link with action=save, recorded once per recipient.
<div class="pv-list">
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=product-1&blockType=product&action=buy&variant=product-variant-2" ...>S / Navy · $56.00</a>
<a href="...&variant=product-variant-3" ...>L / Navy · $60.00</a>
</div>
<p style="margin:10px 0 0;font-size:13px">
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=product-1&blockType=product&action=save">♡ Save for later</a>
</p>
Product grid
The grid is one table of cards, each its own bordered table, with cells that stack on phones. Each card's button is a click link under the card's own id (blockType=product-card). Prices and default variants of imported cards are read from the synced catalogue at render time.
<td width="181" class="mia-stk" style="width:33%;vertical-align:top">
<table role="presentation" width="100%" style="border:1px solid #e5e7eb;border-radius:8px;background-color:#ffffff">
<tr><td style="padding:12px 12px 0;text-align:center">
<img src="https://shop.example.com/tee.jpg" alt="Linen tee" width="155" style="display:block;width:100%;height:auto">
<p style="margin:0 0 4px;font-weight:600;font-size:15px">Linen tee</p>
<p style="margin:0 0 10px;font-weight:700;font-size:15px">$28.00</p>
</td></tr>
<tr><td style="padding:0 12px 12px;text-align:center">
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=product-card-1&blockType=product-card&dest=https%3A%2F%2Fshop.example.com%2Fproducts%2Ftee&sig=..." ...>Shop now</a>
</td></tr>
</table>
</td>
With Add to cart, a cart card's button links to the cart page /v/[token]/cart/[blockId]?add=<cardId> instead. That page, and the live view's grid, post the picked item ids and qty_<cardId> to /api/cart, which reads the cards and the store from the stored email and redirects to Shopify's cart permalink or WooCommerce's checkout link. The checkout is recorded as a click on the grid, with the picked cards and quantities in its value.
Coupon
The code is plain text in a box styled with user-select:all, so a tap or double-click selects all of it. The shop button is a click link. In the live view, the inbox and the app, the box is a <button data-copy> that copies the code.
<div style="background-color:#fff7ed;text-align:center">
<p style="margin:0 0 10px;font-size:15px;font-weight:700;color:#111827">Your exclusive discount</p>
<p style="display:inline-block;margin:0;padding:12px 24px;border:2px dashed #4f46e5;border-radius:8px;background-color:#ffffff;font-size:26px;font-weight:800;letter-spacing:3px;color:#4f46e5;-webkit-user-select:all;user-select:all">SAVE20</p>
<p style="margin:12px 0 0;font-size:13px;color:#6b7280">20% off until Sunday. Applied at checkout.</p>
</div>
A code from a merge tag is resolved per recipient; when it resolves empty, the block isn't rendered.
Store reviews
Store reviews are static text: the stars are text glyphs with an aria-label, and each review's text carries dir="auto". The reviews are picked at render time from the synced storeReviews and are never stored in the email's tree. With One product, the "Read all reviews" link is a click link to the product page.
<p style="margin:0 0 14px;font-size:15px;color:#111827">
<span role="img" aria-label="Rated 4.6 out of 5" style="color:#f59e0b">★★★★★</span> 4.6 from 212 reviews
</p>
<table role="presentation" width="100%">
<tr><td style="padding:0 0 14px;border-bottom:1px solid #e5e7eb">
<p style="margin:0 0 6px"><span role="img" aria-label="Rated 5.0 out of 5" style="color:#f59e0b">★★★★★</span></p>
<p dir="auto" style="margin:0 0 4px;font-weight:700">Bright and floral</p>
<p dir="auto" style="margin:0">Blueberry and jasmine notes, exactly as described.</p>
<p dir="auto" style="margin:6px 0 0;font-size:12px;color:#6b7280">Amira H. · Verified buyer · Nov 2, 2026</p>
</td></tr>
</table>
The live view, the inbox and GET /api/v1/liveview/[token] read the reviews again on every open.
Event blocks
RSVP and Meeting booking record through confirm links, like the Feedback blocks. The Join button of a meeting link and the Register button of a webinar signup are click links through /v/[token]/click, like the Shop blocks' links.
Meeting link
The status line ("Starts in …", or "Live now" once the start has passed) is written when the email is rendered. Under it, an <img> from /api/countdown, signed like the Countdown block's, draws the time left each time the email is opened. In mail, the Join button is always a live click link.
<div style="margin:12px 0;text-align:left;background-color:transparent">
<p style="margin:0 0 6px;font-size:13px;font-weight:600;color:#111827">Starts in 2d 3h 30m</p>
<img src="https://mailinapp.com/api/countdown?t=1768663800000&c=111827&s=..."
width="357" height="81" alt="Starts in 2d 3h 30m" style="display:inline-block;max-width:100%;height:auto;margin-bottom:8px">
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=meeting-link-1&blockType=meeting-link&dest=https%3A%2F%2Fmeet.google.com%2Fabc-defg-hij&sig=..."
style="display:inline-block;padding:10px 20px;background-color:#4f46e5;color:#ffffff;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600">
Join on Google Meet
</a>
<p style="margin:8px 0 0;font-size:13px;color:#4b5563">Dial in: +1 555-0100, PIN 1234</p>
</div>
The live view, the inbox and the mobile app show the Join button only from Join link opens before the start minutes before startsAt, worked out from the block's props at render time with no stored state. Until then they show an inert "Opens N minutes before start" chip. A block without startsAt is always open.
RSVP
Each answer is a confirm link carrying response=yes, no or maybe. With Allow bringing guests, Yes links to the live view, where the reader picks a number of guests. Show how many are going adds an <img> from /api/rsvp-count, signed per block, colour and width, never per recipient, and drawn from the RSVP rollup when it's opened.
<div id="em-rsvp-1" style="margin:12px 0;background-color:transparent">
<p style="margin:0 0 10px;font-weight:600;font-size:16px;color:#111827">Coming to the launch?</p>
<p style="margin:0 0 10px;font-size:12px;color:#6b7280">Limited to 80 spots</p>
<img src="https://mailinapp.com/api/rsvp-count?p=proj123&b=rsvp-1&c=4f46e5&w=320&s=..."
alt="How many people are going" width="320" height="28" style="display:block;width:100%;max-width:320px;height:auto;border:0">
<div>
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=rsvp-1&blockType=rsvp&action=rsvp&response=yes" ...>Yes</a>
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=rsvp-1&blockType=rsvp&action=rsvp&response=maybe" ...>Maybe</a>
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=rsvp-1&blockType=rsvp&action=rsvp&response=no" ...>No</a>
</div>
</div>
The capacity check and the per-recipient dedup run in one Firestore transaction, so places are never oversold: a yes past the capacity is recorded as waitlisted, a no as declined, a maybe as maybe with no place. The questions after a yes are posted as a submit on the block id plus __details, which the server accepts only from a recipient whose recorded answer is a yes, and checks like a form's answers.
Meeting booking
The times are the booking type's next open slots, computed when the email is rendered and labelled in the booking type's time zone. In mail, each time is a confirm link with action=book&slot=<epoch ms>, and See more times opens the live booking page /v/[token]/book/[blockId].
<div id="em-booking-1" style="margin:12px 0;background-color:transparent">
<p style="margin:0 0 10px;font-weight:600;font-size:16px;color:#111827">Book a time with us</p>
<p style="margin:0 0 8px;font-size:13px;color:#6b7280">Times in Eastern Time</p>
<div class="bk-panels">
<div id="em-booking-1-g0" class="bk-p">
<p class="bk-dh" style="margin:6px 0 4px;font-size:12px;font-weight:600;color:#374151">Monday, January 19</p>
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=booking-1&blockType=booking&action=book&slot=1768831200000" ...>9:00 AM</a>
<a href="https://mailinapp.com/v/eyJhbGci.../act?blockId=booking-1&blockType=booking&action=book&slot=1768834800000" ...>10:00 AM</a>
</div>
</div>
<p style="margin:8px 0 0;font-size:13px">
<a href="https://mailinapp.com/v/eyJhbGci.../book/booking-1" style="color:inherit;text-decoration:underline">See more times</a>
</p>
</div>
With Show days as tabs, one hidden radio per day (#<id>-d<i>) comes before a tab bar (.bk-bar), and rules of the form #<id>-d<i>:checked:not(:disabled) ~ … show one day's panel (.bk-p). Where those rules don't run, every panel shows under its day heading (.bk-dh). In the live view, the inbox and the app, the times are radio chips in one form that posts action=book with the picked slot to /api/interactions.
Before booking, the server reads the calendar's free/busy again and claims the slot in a transaction, so one slot is booked once. A recipient is booked as their own contact, once per block. A token with no contact behind it is sent to the booking page, which asks for a name and email behind a bot check.
Webinar signup
The card is the same in every host. The date is formatted in the block's time zone with the zone named, and Register now is a click link to the session's public page /webinar/<liveSessionId>, built from the session id with no lookup at send time.
<div style="margin:12px 0;background-color:transparent">
<img src="https://example.com/webinar-cover.jpg" alt="Office hours"
style="width:100%;max-width:100%;border-radius:6px;display:block;margin-bottom:10px">
<p style="margin:0 0 4px;font-weight:600;font-size:16px;color:#111827">Office hours</p>
<p style="margin:0 0 8px;font-size:13px;color:#6b7280">Mar 1, 2026, 12:00 PM EST</p>
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=webinar-signup-1&blockType=webinar-signup&dest=https%3A%2F%2Fmailinapp.com%2Fwebinar%2Fsess_abc123&sig=..."
style="display:inline-block;padding:10px 20px;background-color:#4f46e5;color:#ffffff;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600">
Register now
</a>
</div>
Registrations are recorded by the session's page, so the block itself records only the click.
Showcase blocks
These blocks record no answer. Each mails its content in a form that reads well on its own, then adds :checked rules that turn it into the interactive version where the email app runs them. The rules sit in the <head> <style>, and the inputs they key on are wrapped in <!--[if !mso]><!--> so classic Outlook never sees them.
Two shapes cover all seven:
- Radio groups (carousel, tabs, image gallery): one hidden radio per slide, tab or picture before the content, with labels
forthose radios as the dots, tab bar or thumbnails. Every rule is written#<radio>:checked:not(:disabled) ~ …. An app that drops the inputs matches none of them, so the fallback stays. - Checkbox toggles (accordion, before / after, image hotspots, menu): an always-ticked gate checkbox
#<id>-kbefore the block, and the toggle#<id>-tinside the<label>that's tapped. The rules that hide anything start from#<id>-k:checked, so an app that drops the gate shows everything.
Links inside these blocks go through /v/[token]/click like any other link.
Carousel
Each slide is drawn twice: once in .carousel-fallback (the first slide and the See all N slides link, or every slide in a .carousel-grid table) and once as a hidden .lv-frame that a radio's rules show. The .lv-px strip loads a slide-view beacon, /v/[token]/nv/<blockId>/<slide>, from the rule of every slide after the first, which is how Insights counts readers who moved past the first slide.
<div id="em-carousel-g1">
<input type="radio" name="em-carousel-g1" id="em-carousel-g1-s0" checked hidden style="display:none">
<input type="radio" name="em-carousel-g1" id="em-carousel-g1-s1" hidden style="display:none">
<div class="carousel-fallback">
<div class="lv-frame lv-frame-0">
<img src="https://cdn.example.com/slide1.jpg" alt="Slide 1" style="width:100%">
<p style="margin:8px 0 0;font-size:14px;color:#374151">Slide 1</p>
</div>
<p style="margin:8px 0 0;font-size:13px">
<a href="https://mailinapp.com/v/eyJhbGci..." style="color:#4f46e5">See all 2 slides →</a>
</p>
</div>
<div class="lv-frames">
<div class="lv-frame lv-frame-0" style="display:none">…</div>
<div class="lv-frame lv-frame-1" style="display:none">…</div>
</div>
<div class="lv-dots" style="display:none;text-align:center">
<label for="em-carousel-g1-s0" class="lv-dot lv-dot-0" aria-label="Slide 1"></label>
<label for="em-carousel-g1-s1" class="lv-dot lv-dot-1" aria-label="Slide 2"></label>
</div>
<div class="lv-px" style="height:4px"> </div>
</div>
#em-carousel-g1-s1:checked:not(:disabled) ~ .carousel-fallback{display:none!important}
#em-carousel-g1-s1:checked:not(:disabled) ~ .lv-dots{display:block!important}
#em-carousel-g1-s1:checked:not(:disabled) ~ .lv-frames .lv-frame-1{display:block!important}
#em-carousel-g1-s1:checked:not(:disabled) ~ .lv-px{background-image:url(https://mailinapp.com/v/eyJhbGci.../nv/carousel-g1/1)}
Arrows are labels for the neighbouring radios inside each frame. Thumbnails replace the dots with .lv-tn labels. Autoplay adds one more radio, checked first, whose rules move the frames along a .lv-track with a @keyframes animation inside @media (prefers-reduced-motion:no-preference); picking a slide unchecks it. A slide's price and button are part of the slide, so they show in the fallback too, and the button links to the slide's own href.
Accordion
The content of each item sits inside the item's <label>, after the toggle, so it shows wherever the rules don't run. In the live view, the inbox and the canvas each item is a native <details>/<summary> instead.
<div id="em-accordion-item-g2" style="border:1px solid #e5e7eb;border-radius:6px;padding:10px 14px">
<input type="checkbox" id="em-accordion-item-g2-k" checked hidden style="display:none">
<label style="display:block;cursor:pointer">
<input type="checkbox" id="em-accordion-item-g2-t" hidden style="display:none">
<span style="display:block;font-weight:600;font-size:15px">Do you offer refunds?</span>
<div class="acc-content" style="margin:8px 0 0;font-size:14px">Yes, within 30 days of purchase.</div>
</label>
</div>
#em-accordion-item-g2-k:checked ~ label .acc-content{display:none}
#em-accordion-item-g2-t:checked ~ div.acc-content{display:block}
Tabs
Each tab's blocks are written once, in a .tb-p panel that opens with the tab's title as a .tb-h heading. Those stacked panels are the fallback. The radios' rules show the .tb-bar, hide the headings and show one panel.
<div id="em-tabs-g1">
<input type="radio" name="em-tabs-g1" id="em-tabs-g1-r0" checked hidden style="display:none">
<input type="radio" name="em-tabs-g1" id="em-tabs-g1-r1" hidden style="display:none">
<div class="tb-bar" role="tablist" style="display:none">
<label for="em-tabs-g1-r0" id="em-tabs-g1-t0" class="tb-t" role="tab">Overview</label>
<label for="em-tabs-g1-r1" id="em-tabs-g1-t1" class="tb-t" role="tab">Details</label>
</div>
<div class="tb-panels">
<div id="em-tabs-g1-p0" class="tb-p"><p class="tb-h" style="font-weight:700">Overview</p>…</div>
<div id="em-tabs-g1-p1" class="tb-p"><p class="tb-h" style="font-weight:700">Details</p>…</div>
</div>
</div>
#em-tabs-g1-r1:checked:not(:disabled) ~ .tb-bar{display:block!important}
#em-tabs-g1-r1:checked:not(:disabled) ~ .tb-panels .tb-h{display:none!important}
#em-tabs-g1-r1:checked:not(:disabled) ~ .tb-panels .tb-p{display:none}
#em-tabs-g1-r1:checked:not(:disabled) ~ .tb-panels #em-tabs-g1-p1{display:block!important}
Before / after
Both pictures sit inside one <label>, each under its caption. The gate's rules hide the after picture and show the hint; the toggle swaps the two.
<div id="em-before-after-g1">
<input type="checkbox" id="em-before-after-g1-k" checked hidden style="display:none">
<label style="display:block;cursor:pointer">
<input type="checkbox" id="em-before-after-g1-t" hidden aria-label="Switch between the before and after pictures" style="display:none">
<div class="ba-before">
<p class="ba-cap">Before</p>
<img src="https://example.com/kitchen-before.jpg" alt="Before: The kitchen" width="568">
<p class="ba-hint" style="display:none">Tap to see after</p>
</div>
<div class="ba-after" style="margin-top:12px">
<p class="ba-cap">After</p>
<img src="https://example.com/kitchen-after.jpg" alt="After: The kitchen" width="568">
<p class="ba-hint" style="display:none">Tap to see before</p>
</div>
</label>
</div>
#em-before-after-g1-k:checked ~ label .ba-after{display:none}
#em-before-after-g1-k:checked ~ label .ba-hint{display:block!important}
#em-before-after-g1-t:checked ~ div.ba-before{display:none}
#em-before-after-g1-t:checked ~ div.ba-after{display:block;margin-top:0!important}
Image hotspots
Pins are placed only by rules behind the gate, never by inline position (which Gmail removes). Each pin is a <label> around its own checkbox and note. The numbered .hs-legend under the picture is the fallback, and the gate's rules hide it.
<div id="em-image-hotspots-g4">
<input type="checkbox" id="em-image-hotspots-g4-k" checked hidden style="display:none">
<div class="hs-stage">
<img src="https://example.com/bike.jpg" alt="Our commuter bike" width="568">
<label id="em-image-hotspots-g4-h0" class="hs-pin" style="display:none">
<input type="checkbox" id="em-image-hotspots-g4-h0-t" hidden aria-label="Hydraulic brakes" style="display:none">
<span class="hs-num">1</span>
<span class="hs-note" style="display:none"><strong>Hydraulic brakes</strong>Stop short in the wet.</span>
</label>
</div>
<div class="hs-legend">
<p><strong>1. Hydraulic brakes</strong> — Stop short in the wet.</p>
</div>
</div>
#em-image-hotspots-g4-k:checked ~ div.hs-stage{position:relative}
#em-image-hotspots-g4-k:checked ~ div.hs-legend{display:none}
#em-image-hotspots-g4-k:checked ~ div.hs-stage #em-image-hotspots-g4-h0{display:block!important;position:absolute;left:20%;top:30%;margin:-13px 0 0 -13px}
#em-image-hotspots-g4-h0-t:checked ~ .hs-note{display:block!important;position:absolute;left:-8px;top:32px}
A note opens to the left or right and up or down depending on where its pin sits, past 60% across or 65% down.
Image gallery
The first picture is always in .gl-main; the others are hidden frames there. .gl-fallback shows them small, each linked to the live view, and the radios' rules swap it for the .gl-thumbs row of labels. The product block draws its extra pictures with the same parts.
<div id="em-image-gallery-g4">
<input type="radio" name="em-image-gallery-g4" id="em-image-gallery-g4-r0" checked hidden style="display:none">
<input type="radio" name="em-image-gallery-g4" id="em-image-gallery-g4-r1" hidden style="display:none">
<div class="gl-main">
<div id="em-image-gallery-g4-f0" class="gl-f"><img src="https://example.com/chair-front.jpg" alt="Chair from the front" width="568"></div>
<div id="em-image-gallery-g4-f1" class="gl-f" style="display:none"><img src="https://example.com/chair-side.jpg" alt="Chair from the side" width="568"></div>
</div>
<div class="gl-fallback">
<a href="https://mailinapp.com/v/eyJhbGci..."><img src="https://example.com/chair-side.jpg" alt="Chair from the side" width="64" height="64"></a>
</div>
<div class="gl-thumbs" style="display:none">
<label for="em-image-gallery-g4-r0" id="em-image-gallery-g4-t0" class="gl-t" aria-label="Picture 1">…</label>
<label for="em-image-gallery-g4-r1" id="em-image-gallery-g4-t1" class="gl-t" aria-label="Picture 2">…</label>
</div>
</div>
#em-image-gallery-g4-r1:checked:not(:disabled) ~ .gl-fallback{display:none!important}
#em-image-gallery-g4-r1:checked:not(:disabled) ~ .gl-thumbs{display:block!important}
#em-image-gallery-g4-r1:checked:not(:disabled) ~ .gl-main .gl-f{display:none!important}
#em-image-gallery-g4-r1:checked:not(:disabled) ~ .gl-main #em-image-gallery-g4-f1{display:block!important}
Menu
The links are one .mn-row, each a click link with its own slot (blockType=menu-item), so Insights names every link. The .mn-bar and the rules that fold the row sit inside @media only screen and (max-width:620px) for On phones, or at the top level for Always.
<div id="em-menu-g5">
<input type="checkbox" id="em-menu-g5-k" checked hidden style="display:none">
<label style="display:block;cursor:pointer">
<input type="checkbox" id="em-menu-g5-t" hidden aria-label="Show or hide the links" style="display:none">
<div class="mn-bar" style="display:none"><span class="mn-open">☰</span><span class="mn-close" style="display:none">✕</span> Menu</div>
<div class="mn-row" style="text-align:center">
<span class="mn-i"><a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=menu-item-g1&blockType=menu-item&dest=https%3A%2F%2Fshop.example.com%2F&sig=...">Shop</a></span>
<span class="mn-sep" aria-hidden="true">|</span>
<span class="mn-i"><a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=menu-item-g2&blockType=menu-item&dest=https%3A%2F%2Fshop.example.com%2Fnew&sig=...">New in</a></span>
</div>
</label>
</div>
@media only screen and (max-width:620px){
#em-menu-g5-k:checked ~ label .mn-bar{display:block!important}
#em-menu-g5-k:checked ~ label .mn-row{display:none}
#em-menu-g5-t:checked ~ div.mn-row{display:block}
#em-menu-g5-t:checked ~ div.mn-row .mn-i{display:block!important}
#em-menu-g5-t:checked ~ div.mn-row .mn-sep{display:none}
}
Game blocks
The three games share one shape. An always-ticked gate checkbox #<id>-k sits before a <label> holding a radio, the cover (.sc-surface, or the wheel .stw-wheel and its button .stw-go) and the prize (.sc-prize, .stw-prize). The gate's rules show the cover and hide the prize. Tapping the label ticks the radio, whose rules hide the cover and show the prize.
A radio, not a checkbox, so a second tap can't hide the prize again. The inputs sit inside <!--[if !mso]><!-->, and an app that drops the gate shows what's outside the rules.
Each block records a reveal. In mail, the radio's rule loads a reveal beacon, /v/[token]/rv/<blockId>, as the background of a 4px strip (.sc-px, .stw-px), and the live view posts the reveal from its inline script. Prize links go through /v/[token]/click.
Prizes. With game-prize children, the server picks each recipient's prize before the email is rendered: a weighted pick seeded by an HMAC of the project, the block and the recipient, recorded once in gamePrizes/{projectId}_{blockId}_{recipient} with its code. The result rides the recipient's row as prize_<blockId>, prize_label_<blockId>, prize_code_<blockId> and prize_url_<blockId>, so mail, the live view, the inbox and the app show one prize.
The prize panel then sits inside the interactive part only, and a Reveal my prize link to the live view (.stw-reveal, .sc-reveal) stands outside it, hidden by the gate's rule. An email rendered without a result on the row (an export, a failed claim) shows only that link, and the live view claims the prize. The reveal event carries the recorded prize, never a posted one.
Spin-to-win
The wheel is a 240px conic-gradient with one equal slice per prize, labelled in white with a shadow so dark mode leaves it readable. Its @keyframes turns it to the angle of the recipient's prize over 3.2 seconds, after which the prize panel fades in. Classic Outlook gets the reveal link as a VML button.
<div id="em-spin-to-win-g5" style="text-align:center">
<p style="font-weight:700;font-size:18px">Spin for a summer treat</p>
<!--[if !mso]><!-->
<input type="checkbox" id="em-spin-to-win-g5-k" checked hidden style="display:none">
<label style="display:block;cursor:pointer">
<input type="radio" id="em-spin-to-win-g5-spin" hidden aria-label="Spin the wheel to reveal your prize" style="display:none">
<span class="stw-ptr" aria-hidden="true" style="display:none">▼</span>
<span class="stw-wheel" aria-hidden="true" style="display:none;width:240px;height:240px;border-radius:50%;
background:conic-gradient(#4f46e5 0deg 90deg,#847eed 90deg 180deg,#3b35ac 180deg 270deg,#f59e0b 270deg 360deg)">
<span style="position:absolute;transform:rotate(45deg)">10% off</span>
…
</span>
<span class="stw-go" style="display:none">Spin the wheel</span>
<div class="stw-prize" role="status" style="display:none">
<p style="font-weight:700">You won: 10% off!</p>
<p>Your next order is 10% off.</p>
<p aria-label="Your code" style="border:2px dashed currentColor;font-family:monospace">SPIN10-AB12</p>
</div>
<div class="stw-px" style="height:4px"> </div>
</label>
<!--<![endif]-->
<div class="stw-reveal">
<a href="https://mailinapp.com/v/eyJhbGci...">Reveal my prize</a>
</div>
</div>
#em-spin-to-win-g5-k:checked ~ label .stw-wheel{display:block!important}
#em-spin-to-win-g5-k:checked ~ label .stw-go{display:inline-block!important}
#em-spin-to-win-g5-k:checked ~ .stw-reveal{display:none!important}
#em-spin-to-win-g5-spin:checked ~ span.stw-wheel{animation:stw-em-spin-to-win-g5 3200ms cubic-bezier(.17,.67,.21,1) both}
#em-spin-to-win-g5-spin:checked ~ div.stw-prize{display:block!important;animation:stw-in-em-spin-to-win-g5 .4s ease-out 3200ms both}
#em-spin-to-win-g5-spin:checked ~ .stw-px{background-image:url(https://mailinapp.com/v/eyJhbGci.../rv/spin-to-win-g5)}
@keyframes stw-em-spin-to-win-g5{from{transform:rotate(0deg)}to{transform:rotate(2115deg)}}
Without prizes, the wheel is a 64px 🎡 that turns twice in 0.9 seconds and reveals one tracked button to the Prize link. A second button to the same link, Reveal your prize, stands outside the interactive part for every other app (a link to the live view when the prize link is empty). The live view shows the title and the prize button.
Scratch-off
Without prizes, the prize stays outside the interactive part, so an app that drops the rules shows it straight away. The cover is a <span> with display:none that only the gate's rule shows: silver stripes, the Cover color or an <img> for the Cover image (never a CSS url()). The Reveal button adds a .sc-go span inside the label.
<div id="em-scratch-card-g1" style="text-align:center">
<p style="font-weight:700;font-size:18px">Scratch to reveal your prize!</p>
<!--[if !mso]><!-->
<input type="checkbox" id="em-scratch-card-g1-k" checked hidden style="display:none">
<!--<![endif]-->
<label style="display:block;cursor:pointer">
<!--[if !mso]><!-->
<input type="radio" id="em-scratch-card-g1-scratch" hidden aria-label="Scratch to reveal the hidden reward" style="display:none">
<span class="sc-surface" style="display:none;padding:24px;border-radius:8px;
background:repeating-linear-gradient(45deg,#9ca3af,#9ca3af 10px,#d1d5db 10px,#d1d5db 20px)">Scratch here</span>
<div class="sc-px" style="height:4px"> </div>
<!--<![endif]-->
<div class="sc-prize" style="margin-top:10px">
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=scratch-card-g1&blockType=scratch-card&dest=…&sig=…">🎉 20% off your next order!</a>
</div>
</label>
</div>
#em-scratch-card-g1-k:checked ~ label #em-scratch-card-g1-scratch{display:block!important;position:absolute;width:1px;height:1px;opacity:0}
#em-scratch-card-g1-k:checked ~ label .sc-surface{display:block!important}
#em-scratch-card-g1-k:checked ~ label .sc-prize{display:none!important}
#em-scratch-card-g1-scratch:checked ~ span.sc-surface{display:none!important}
#em-scratch-card-g1-scratch:checked ~ div.sc-prize{display:block!important}
#em-scratch-card-g1-scratch:focus ~ .sc-surface{outline:3px solid #4f46e5;outline-offset:2px}
#em-scratch-card-g1-scratch:checked ~ .sc-px{background-image:url(https://mailinapp.com/v/eyJhbGci.../rv/scratch-card-g1)}
The gate's rule makes the radio a 1px focusable element, which is how Tab reaches the card and Space reveals it. With Button below the card, the tracked button sits after the </label>, outside every rule, so it shows before and after the scratch.
Mystery box
The scratch-off's markup and rules, with a gift box for the cover: a 72px 🎁 (or the Box image) and the tap text. One more rule wobbles the box while it's closed.
<label style="display:block;cursor:pointer">
<input type="radio" id="em-mystery-box-g1-scratch" hidden aria-label="Open the mystery box to reveal your prize" style="display:none">
<span class="sc-surface" style="display:none;padding:8px 0">
<span class="sc-box" aria-hidden="true" style="display:inline-block;font-size:72px">🎁</span>
<span style="display:block;font-weight:700">Tap the box to open it</span>
</span>
…
</label>
#em-mystery-box-g1-k:checked ~ label .sc-box{animation:mb-em-mystery-box-g1 2.4s ease-in-out infinite}
@keyframes mb-em-mystery-box-g1{0%,70%,100%{transform:rotate(0deg)}76%{transform:rotate(-8deg)}82%{transform:rotate(7deg)}88%{transform:rotate(-4deg)}94%{transform:rotate(2deg)}}
Learning blocks
The flashcard deck records nothing. The assignment records one hand-in per recipient.
Flashcard deck
Each card has the before / after shape: an always-ticked gate #<card>-k, then a <label> holding the card's own checkbox #<card>-f, the front .fc-front and the back .fc-back. The gate's rules hide the back and the side labels .fc-l. Ticking the card's checkbox hides the front and shows the back.
Every rule names :checked, so an app that drops them shows the front and the back stacked, the back under a dashed rule, each side opening with its label ("Q: " and "A: ", in the email's language). A card that already starts with its label keeps it once. A card with a picture on the front only keeps a 200px height when turned, so the deck doesn't move under the reader's finger. The live view draws the same markup, and the plain-text part writes each card as two lines.
<div id="em-flashcard-g2" style="border:1px solid #e5e7eb;border-radius:8px;padding:14px;margin-bottom:8px;text-align:center">
<!--[if !mso]><!-->
<input type="checkbox" id="em-flashcard-g2-k" checked hidden style="display:none">
<!--<![endif]-->
<label style="display:block;cursor:pointer">
<!--[if !mso]><!-->
<input type="checkbox" id="em-flashcard-g2-f" hidden style="display:none">
<!--<![endif]-->
<div class="fc-front">
<p style="margin:0;font-weight:600;font-size:16px"><span class="fc-l">Q: </span>What is the powerhouse of the cell?</p>
</div>
<div class="fc-back" style="margin-top:10px;padding-top:10px;border-top:1px dashed #e5e7eb">
<p style="margin:0;font-size:16px"><span class="fc-l">A: </span>The mitochondria</p>
</div>
</label>
</div>
#em-flashcard-g2-k:checked ~ label .fc-back{display:none}
#em-flashcard-g2-k:checked ~ label .fc-l{display:none}
#em-flashcard-g2-f:checked ~ div.fc-front{display:none}
#em-flashcard-g2-f:checked ~ div.fc-back{display:block;margin-top:0!important;padding-top:0!important;border-top:0!important}
Assignment
The due date is the countdown block's image, /api/countdown signed for the deadline, under a "Due" line. Mail writes no time left, since it's read after it's rendered, and the image's alt text reads "Time left before it's due". An email rendered after the deadline says "Past due" instead. The live view writes the time left ("Due in 2d 4h 10m"). Resource links are plain links, and Points adds "(10 pts)" to the title.
Mark as done is a choice like a poll's: in mail, one link to /v/[token]/act?action=complete, where the reader confirms. A short text or link answer is a <form> posting action: "submit-answer" with answer (a three-line <textarea> or an <input type="url">) to /api/interactions, inside <!--[if !mso]>, with an Answer on the web link to the live view (#em-<id>) under it in every app.
A hand-in is deduped per recipient like a vote, and the live view reads it back: "Marked as done ✓", or "Handed in ✓" with the answer. A hand-in after dueAt is recorded like any other, and Insights reads on time or late from its time (homeworkBlocks).
<div id="em-assignment-g2">
<p style="margin:0 0 4px;font-weight:700;font-size:18px">Read chapter 4 (10 pts)</p>
<p style="margin:0 0 10px;font-size:14px;color:#4b5563">Summarize the main themes in 2-3 sentences.</p>
<p style="margin:0 0 6px;font-size:13px;font-weight:600">Due</p>
<img src="https://mailinapp.com/api/countdown?t=1768663800000&c=111827&s=…" width="357" height="81"
alt="Time left before it's due" style="display:block;max-width:100%;height:auto;margin-bottom:8px">
<div style="margin:0 0 10px">
<p style="margin:0 0 4px;font-size:13px"><a href="https://example.com/ch4.pdf">Chapter 4 PDF</a></p>
</div>
<div>
<!--[if !mso]><!-->
<form method="post" action="https://mailinapp.com/api/interactions?campaignId=…&blockId=assignment-g2&redirect=…">
<!-- hidden campaignId, blockId, blockType, action=submit-answer, rcpt, redirect -->
<textarea name="answer" rows="3" placeholder="Your answer" required></textarea>
<button type="submit">Submit answer</button>
</form>
<!--<![endif]-->
<p style="margin:8px 0 0;font-size:13px;text-align:center">
<a href="https://mailinapp.com/v/eyJhbGci...#em-assignment-g2">Answer on the web</a>
</p>
</div>
</div>
Content blocks
These blocks record no answers. Video, Audio, Venue and Add to calendar are click slots: in a personalized send, each link goes through /v/[token]/click?blockId=…&blockType=…&dest=…&sig=…, which records a click on the block and redirects to dest. An exported email with no recipient token links straight to the destination. The mailed markup is the same in every email app; only the live view differs, for video and audio.
Video and audio
Mail draws a picture inside the click link: the poster or cover as a plain <img> whose alt is the description, or, without one, a dark panel with ▶ or ♪, the description and, for a video, the duration as M:SS. The block's width, padding, border and background sit on the outer <div>, so the panel keeps its own padding.
The live view and MailInApp's inbox draw a <video controls> with the poster as poster, or an <audio controls> under the cover <img>, each with the description as aria-label. The mobile app opens the file. A block with no src emits nothing.
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=video-g1&blockType=video&dest=https%3A%2F%2Fexample.com%2Fpromo.mp4&sig=…">
<div style="box-sizing:border-box;overflow:hidden;width:100%;max-width:100%">
<img src="https://example.com/promo-poster.jpg" alt="Product demo" style="display:block;width:100%;max-width:100%" />
</div>
</a>
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=audio-g2&blockType=audio&dest=https%3A%2F%2Fexample.com%2Fno-cover.mp3&sig=…">
<div style="box-sizing:border-box;overflow:hidden;width:100%;max-width:100%">
<div style="background-color:#111827;color:#ffffff;text-align:center;padding:40px 16px;font-size:18px;font-weight:600">♪ Audio</div>
</div>
</a>
Formula
The formula is a PNG from GET /api/formula. The notation (cut to 300 characters), the display mode and the colour are serialized into the signed query, so the endpoint reads nothing from Firestore and answers with an immutable cache header; the edge worker serves it. The emitter lays the formula out once to write the <img>'s width and height, so the email doesn't reflow while it loads, and the layout steps down in scale to stay within the image size budget. The alt is the notation itself, and so is the plain-text part.
The parser is MailInApp's own (no TeX engine): an unknown macro is drawn as its literal text, and the renderer never throws, so a formula never stops a send. \ce{…} subscripts element counts, superscripts trailing charges and draws -> as an arrow. An empty notation emits nothing. Mail, the live view and the inbox draw the same image; only the URL's origin differs.
<div style="margin:8px 0;text-align:center">
<img src="https://mailinapp.com/api/formula?d=eyJub3RhdGlvbiI6…&s=…" width="385" height="91"
alt="x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}"
style="display:inline-block;max-width:100%;height:auto;vertical-align:middle" />
</div>
Venue
The photo, name and address are plain HTML, and the address keeps its line breaks. The directions link is the Google Maps link as pasted, else https://maps.google.com/?q=<lat>,<lng> when the coordinates are non-zero and in range, else https://maps.google.com/?q=<address>; no Maps API key is involved. With none of the three, no button is drawn. The button is the bulletproof button every block uses: a VML v:roundrect for classic Outlook and an <a> with mso-hide:all for everyone else, both through the click slot.
<div style="margin:12px 0">
<img src="https://example.com/venue.jpg" alt="Grand Hall" style="width:100%;max-width:100%;border-radius:6px;display:block;margin-bottom:10px" />
<p style="margin:0 0 4px;font-weight:600;font-size:16px;color:#111827">Grand Hall</p>
<p style="margin:0 0 10px;font-size:14px;color:#4b5563">123 Main St, Springfield</p>
<!--[if mso]><v:roundrect href="https://mailinapp.com/v/eyJhbGci.../click?blockId=venue-g2&…" …><center>Get Directions</center></v:roundrect><![endif]-->
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=venue-g2&blockType=venue&dest=https%3A%2F%2Fmaps.google.com%2F%3Fq%3D123%2520Main%2520St%252C%2520Springfield&sig=…"
style="display:inline-block;padding:10px 20px;background-color:#4f46e5;color:#ffffff;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600;mso-hide:all">Get Directions</a>
</div>
Add to calendar
The three buttons are drawn only with a valid Starts at; an end that's missing or before the start becomes one hour after it. Title, description and location are cut to 200, 2,000 and 300 characters before any link is built, so the three always agree. All three share the block's one click slot.
- Download .ics is
GET /api/calendar, with the whole event signed into the query (an HMAC over acalendar:-prefixed input, so no other signed-URL family verifies here, and no Firestore read). It streams an RFC 5545 file withDTSTART/DTENDas UTC instants (a trailingZ, noVTIMEZONE), so each calendar shows the guest's own time. TheUIDis a SHA-256 of the event's fields, so saving it again updates one entry. Text is escaped per §3.3.11 and lines are folded at 75 octets. - Add to Google Calendar is a
calendar.google.com/calendar/render?action=TEMPLATE&…link, and Add to Outlook.com anoutlook.live.com/calendar/0/action/compose?…link, both built at render time.
With Show only after a yes (afterRsvp), mail emits nothing; the live view, the inbox and the mobile app emit the block once the recipient's recorded RSVP in the email is confirmed. The studio canvas, which has no server secret, draws the .ics button with a # link.
<div style="margin:12px 0">
<p style="margin:0 0 8px;font-weight:600;font-size:16px;color:#111827">Q3 Product Launch, Webinar</p>
<p style="margin:0 0 10px;font-size:14px;color:#4b5563">Join us for the big reveal & Q&A.</p>
<a href="https://mailinapp.com/v/eyJhbGci.../click?blockId=add-to-calendar-g2&blockType=add-to-calendar&dest=https%3A%2F%2Fmailinapp.com%2Fapi%2Fcalendar%3Fd%3D…&sig=…"
style="display:inline-block;padding:10px 20px;background-color:#4f46e5;color:#ffffff;border-radius:6px;text-decoration:none;font-size:14px;font-weight:600;margin:0 8px 8px 0;mso-hide:all">Download .ics</a>
<!-- Add to Google Calendar and Add to Outlook.com follow, each through the same click slot -->
</div>
Chart blocks
The charts, the KPI scorecard and the standings table record nothing and hold no links. Mail, the live view and MailInApp's inbox write the same markup; only the image URL's origin differs. Every word they add (table headings, the gauge's zones, the standings columns, the folded Other slice) comes from emailBlocks.json chart.* and standings.* in the email's language.
- The picture. Each chart, and the scorecard's sparkline, is one PNG from
GET /api/analytics/chart?d=…&s=…&r=2.dis the whole chart spec (type, size, labels, values, colours) as base64url JSON,sits HMAC overLIVEVIEW_SECRET, andrthe pixel ratio. The endpoint reads nothing from Firestore, so a response is a pure function of its signed query and carries an immutable cache header; the edge worker draws and serves it. A spec longer than 6,000 characters, or past a chart's own caps, is refused. Labels are cut to the spec's label length before signing. - Text beside the picture. The
<img>'saltnames the chart and lists every value it draws ("Bar chart: North (Revenue 12,400); …"). Every chart but the gauge follows it with an always-visible<table aria-label="<title>">of the same figures, with a legend where the chart needs one (several series, slices, tiles or a colour scale). The table lists what the picture draws, except the sankey's, which lists every authored flow. - Bound charts. The KPI scorecard and the bar, line and pie charts take a
binding. A data-source binding is grouped bygroupByFieldand aggregated per series (sum,avg,count,latest;src/lib/charts/aggregate.ts) over the binding's rows, after the block'sfilter, whose values may hold recipient merge tags. An@response:binding reads the project's results rollup (src/lib/charts/responseSource.ts). Both resolve at render: in mail when the email is sent, in the live view on each load. A filter with a recipient tag makes a spec, and so an image URL, per recipient. - Empty data. A chart with no usable rows writes its title and a notice (
chart.emptyRowsand its siblings) in place of the picture, so a half-built block never stops a send.
| Chart | Table columns | Caps |
|---|---|---|
| Bar, line, radar | Category, then one per named series | 24 categories, 3 series; radar 3 to 8 axes |
| Pie, treemap | Category, Value, Percent | 8 slices: the 7 largest plus Other |
| Scatter | Series, X, Y, and Size in a bubble chart | 120 points, 8 series |
| Histogram | Range, Count | 500 values, 2 to 20 bins |
| Heatmap | Row, Column, Value (authored cells only) | 12 rows × 24 columns |
| Funnel | Stage, Value, % of first, % of previous | 8 stages |
| Waterfall | Label, Value, Type, Running total | 8 bars |
| Sankey | From, To, Value | 12 nodes, 24 links |
A row past a cap is dropped, never merged, except the pie's and the treemap's smallest slices. The funnel and the waterfall keep the authored order, which is their meaning.
Charts with a table
<div style="margin:0;padding:0;background-color:#ffffff">
<p style="margin:0 0 8px;font-weight:600;font-size:15px;color:#111827">Revenue by region</p>
<img src="https://mailinapp.com/api/analytics/chart?d=eyJ0eXBlIjoiYmFyIi…&s=Ev3iTLfo…&r=2" width="560" height="280"
alt="Bar chart: North (Revenue 12,400); South (Revenue 9,800); East (Revenue 14,200)"
style="display:block;max-width:100%;height:auto;margin:8px 0" />
<table aria-label="Revenue by region" style="width:100%;border-collapse:collapse;margin-top:4px">
<tr><th scope="col" style="text-align:left;padding:4px 8px;font-size:12px;color:#6b7280;font-weight:600">Category</th>
<th scope="col" style="text-align:left;padding:4px 8px;font-size:12px;color:#6b7280;font-weight:600">Revenue</th></tr>
<tr><td style="text-align:left;padding:4px 8px;font-size:12px;color:#6b7280">North</td>
<td style="text-align:left;padding:4px 8px;font-size:12px;color:#6b7280">12,400</td></tr>
<!-- one row per category -->
</table>
</div>
KPI scorecard
The label, the value (formatted as a number, US dollars or a percent) and the change are text. The change appears only with both previousValue and trendDirection set: the percentage is computed from the two values, while the arrow and its status colour (up green, down red, flat amber) follow the authored direction. The sparkline image needs at least two points and takes up to 60; its colour follows the arrow's. A muted line repeats the result as text for screen readers and the plain-text part.
GET /api/v1/liveview/[token] hands the mobile app these words as additive props, worked out by the same kpiDisplay/gaugeDisplay mail uses (attachChartImageUrls, src/lib/liveview/chartImages.ts): displayValue, displayChange/displayChangeColor or displayStatus/displayStatusColor, displaySummary, and displayNotice for a gauge without a number. Every other chart gets chartTable, the always-visible table as JSON {headers, rows}, read off the same markup.
<div style="margin:0;padding:0;background-color:#ffffff">
<p style="margin:0 0 4px;font-weight:600;font-size:13px;color:#6b7280">Monthly revenue</p>
<p style="margin:0 0 6px;font-weight:700;font-size:32px;color:#111827">$48,210 <span style="font-size:14px;font-weight:600;color:#16a34a">▲ +17.6%</span></p>
<img src="https://mailinapp.com/api/analytics/chart?d=eyJ0eXBlIjoic3BhcmtsaW5lIi…&s=…&r=2" width="160" height="40"
alt="Trend sparkline, upward: 10, 14, 12, 18, 22, 27" style="display:block;max-width:100%;height:auto;margin:4px 0" />
<p style="margin:4px 0 0;font-size:11px;color:#6b7280">Monthly revenue — $48,210 — ▲ +17.6% vs previous</p>
</div>
Gauge chart
The gauge is the one chart without a table: its value and zone are text beside the dial. By default the zones ascend: value <= goodMax is good, <= warningMax warning, anything above serious, in the theme's status colours. With higherIsBetter, value >= goodMin is good, >= warningMin warning and anything below serious; the image still draws three ascending bands (gaugeSpecBands in src/lib/charts/gauge.ts hands it warningMin and goodMin with the good and serious colours swapped), so the signed spec format is unchanged. The three props have no defaults, so a gauge without them mails as before. min >= max or thresholds out of order are clamped rather than refused. A value that doesn't parse as a number (an unresolved merge tag, for example) writes chart.emptyGauge in place of the dial.
<div style="margin:0;padding:0;background-color:#ffffff">
<p style="margin:0 0 4px;font-weight:600;font-size:13px;color:#6b7280">Score</p>
<p style="margin:0 0 6px;font-weight:700;font-size:32px;color:#111827">72 <span style="font-size:14px;font-weight:600;color:#d97706">Warning</span></p>
<img src="https://mailinapp.com/api/analytics/chart?d=eyJ0eXBlIjoiZ2F1Z2Ui…&s=…&r=2" width="320" height="200"
alt="Gauge: 72 of 0–100 (Warning)" style="display:block;max-width:100%;height:auto;margin:8px 0" />
<p style="margin:4px 0 0;font-size:11px;color:#6b7280">Score — 72 (Warning) — scale 0–100</p>
</div>
Standings table
A plain <table> with no image. Rows are sorted by Points descending with a stable sort, so ties keep the authored order; the first three ranks show 🥇🥈🥉. showDraws: false removes the D column from the header and every row. highlightTeamName matches a team case-insensitively and bolds and tints its row. No team writes standings.empty.
<table aria-label="Standings" style="width:100%;border-collapse:collapse">
<tr><th scope="col" style="text-align:left;padding:4px 8px;font-weight:600">#</th>
<th scope="col" style="text-align:left;padding:4px 8px;font-weight:600">Team</th>
<!-- P, W, D, L, PF, PA -->
<th scope="col" style="padding:4px 8px;text-align:right;font-weight:600">Pts</th></tr>
<tr><td style="text-align:left;padding:4px 8px">🥇 1</td>
<td style="text-align:left;padding:4px 8px">Eagles</td>
<!-- 10, 7, 2, 1, 24, 10 -->
<td style="padding:4px 8px;text-align:right">23</td></tr>
</table>