Files
davidandClaude Opus 5.5 d23d5e2a87 Phase 2 part 7: the end of the funnel
Posts can be written for a buying signal: the prompt gets its hypothesis
and angle, and links carry its campaign tag. Plausible (Stats API v2) is
read once a day for visitors on tagged links, recorded per signal as
Visited. Stripe (restricted key) is read every hour: $0 checkouts are
Signed up, paid invoices and one-time payments are Paid with their value,
tied to a signal by the checkout's utm_campaign metadata or the payer's
email. The Core's Cal.com has no API, so booking emails from Cal.com in
the outreach mailbox count as Booked. New Settings → Website & sales;
the signal page lists its posts and tagged links. Schema 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:42:03 -07:00

69 lines
4.8 KiB
HTML

{{define "content"}}{{template "settings-start" .}}{{with .Data}}
<h2>Website &amp; sales</h2>
<p class="lede">The end of the funnel: who came to your websites from a link tagged with a buying signal, who booked a call, and who signed up or paid. Supermarket only reads these. Results appear on <a href="/signals">Signals</a>.</p>
<form method="post" action="/settings/tracking" autocomplete="off">
<section class="card" id="plausible">
<h3>Plausible: visits</h3>
<p class="small">Once a day, Supermarket reads yesterday's visitors who arrived on a link tagged with a signal's campaign (<code>utm_campaign</code>), by where the link was (source, medium and content). Visits are counted per signal, never per person.</p>
<label>Plausible's address <input name="plausible_url" value="{{.PlausibleURL}}" placeholder="https://plausible.example.com"></label>
{{template "key-field" (dict "F" .PlausibleKey "Set" .PlausibleSet)}}
<p class="help">Sites read: {{if .Sites}}{{range $i, $s := .Sites}}{{if $i}}, {{end}}<code>{{$s}}</code>{{end}}{{else}}none yet: add your websites (and their Plausible site, if it differs from the domain) to the <a href="/settings/profile">profile</a>{{end}}.</p>
{{if .PlausibleSet}}
<div class="row">
<button type="button" class="secondary small" hx-post="/settings/tracking/test/plausible" hx-target="#test-plausible" hx-indicator="#testing-plausible">Test</button>
<button type="submit" class="secondary small" formaction="/settings/tracking/run/plausible" formnovalidate>Import now</button>
<span id="testing-plausible" class="htmx-indicator">Checking…</span>
</div>
<div id="test-plausible"></div>
{{end}}
{{template "last-run" .LastPlausible}}
</section>
<section class="card" id="stripe">
<h3>Stripe: sign-ups and payments</h3>
<p class="small">Every hour, Supermarket reads new completed checkouts and paid invoices. A checkout with nothing to pay (a trial or a free plan) counts as <strong>Signed up</strong>; money paid counts as <strong>Paid</strong>, with the amount, renewals included. Each customer is tied to a signal by the campaign their checkout carries, or else by their email: a prospect's, or one at a prospect company's domain.</p>
{{template "key-field" (dict "F" .StripeKey "Set" .StripeSet)}}
<details class="small">
<summary>What the shopping cart needs to do</summary>
<p>When a visitor arrives with UTM tags on the link, the cart keeps them (in a cookie or the session) and passes them to Stripe when it creates the Checkout Session, as metadata:</p>
<pre class="sample">metadata[utm_campaign] = the signal's campaign tag
metadata[utm_source] = e.g. email, linkedin, x
metadata[utm_medium] = e.g. outreach, social
metadata[utm_content] = optional: which message or post</pre>
<p>Without them, a payment is still counted, and tied to a signal when the payer's email belongs to a prospect.</p>
</details>
{{if .StripeSet}}
<div class="row">
<button type="button" class="secondary small" hx-post="/settings/tracking/test/stripe" hx-target="#test-stripe" hx-indicator="#testing-stripe">Test</button>
<button type="submit" class="secondary small" formaction="/settings/tracking/run/stripe" formnovalidate>Sync now</button>
<span id="testing-stripe" class="htmx-indicator">Checking…</span>
</div>
<div id="test-stripe"></div>
{{end}}
{{template "last-run" .LastStripe}}
{{if .Customers}}
<table class="list">
<thead><tr><th>Customer</th><th>Came from</th><th>Prospect</th></tr></thead>
<tbody>{{range .Customers}}<tr><td>{{or .Name .Email}}{{if and .Name .Email}} <span class="muted small">{{.Email}}</span>{{end}}</td>
<td class="small">{{if .Campaign}}{{.Campaign}} · {{end}}{{channel .Channel}}</td>
<td class="small">{{if hasPrefix .Subject "stripe:"}}<span class="muted">no</span>{{else}}yes{{end}}</td></tr>{{end}}</tbody>
</table>
{{end}}
</section>
<section class="card" id="bookings">
<h3>Cal.com: bookings</h3>
<p class="small">Your Core's Cal.com has no API, so bookings are read from the emails Cal.com sends you about them, in the mailbox under <a href="/settings/email">Settings → Email</a>. Each new booking counts as <strong>Booked</strong> for the person who booked.</p>
{{if .BookingFrom}}<p class="ok small">Looking for booking emails from <code>{{.BookingFrom}}</code>.</p>
{{else}}<p class="warn-text small">Give Cal.com's sending address under <a href="/settings/email">Settings → Email</a> to start.</p>{{end}}
</section>
<div class="actions"><button type="submit">Save</button></div>
</form>
{{end}}{{template "settings-end"}}{{end}}
{{define "last-run"}}{{with .}}
<p class="small {{if .Error}}error-text{{else}}muted{{end}}">Last read {{ago .At}}: {{if .Error}}{{.Error}}{{else}}{{.Detail}}{{if .Through}} Through {{.Through}}.{{end}}{{end}}</p>
{{end}}{{end}}