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>
This commit is contained in:
2026-11-22 06:42:03 -07:00
co-authored by Claude Opus 5.5
parent 90d73cf907
commit d23d5e2a87
32 changed files with 1775 additions and 26 deletions
@@ -86,6 +86,12 @@
<span class="help">One subreddit per post. Its rules are read and followed when writing{{if .Subreddits}}; suggestions come from this entry and your profile{{end}}.</span>
</label>
</fieldset>
{{if .Signals}}
<label>For a buying signal <span class="muted small">(optional)</span>
<select name="signal"><option value="0">none: plain news for your audience</option>{{range .Signals}}<option value="{{.ID}}">{{.Name}}</option>{{end}}</select>
<span class="help">The posts speak to people in that situation, and their links carry its campaign tag, so visits and sign-ups count for it on the scorecard.</span>
</label>
{{end}}
<fieldset class="choice">
<legend>Posts</legend>
<label class="check"><input type="radio" name="mode" value="one" checked> One post from all selected items</label>
+2
View File
@@ -45,6 +45,8 @@
<label class="check"><input type="checkbox" name="weekends" {{if $s.Weekends}}checked{{end}}> Send on weekends too</label>
<label>Scheduling link <span class="muted small">(optional)</span> <input name="scheduling_link" value="{{$s.SchedulingLink}}" placeholder="https://cal.example.com/you/30min">
<span class="help">Offered as the next step when a call fits. Booking through it counts as Booked once Cal.com is connected.</span></label>
<label>Cal.com's sending address <span class="muted small">(optional)</span> <input name="booking_from" value="{{$s.BookingFrom}}" placeholder="the From address of Cal.com's booking emails">
<span class="help">Cal.com emails you about every booking. With its address here, each new booking email in this mailbox counts as Booked for the person who booked (cancellations and reschedules don't). Open one of those emails and copy its From address. Needs the inbox reading above.</span></label>
<label>Signature <textarea name="footer" rows="5">{{$s.Footer}}</textarea>
<span class="help">Added under every email. Keep a way to opt out: a reply of “stop” puts the address on your suppression list.</span></label>
</section>
+1
View File
@@ -94,6 +94,7 @@
<a href="/settings/core" {{if eq .Nav "settings/core"}}aria-current="page"{{end}}>{{template "icon" "core"}}Core &amp; Hermes</a>
<a href="/settings/sources" {{if eq .Nav "settings/sources"}}aria-current="page"{{end}}>{{template "icon" "prospects"}}Lead sources</a>
<a href="/settings/email" {{if eq .Nav "settings/email"}}aria-current="page"{{end}}>{{template "icon" "email"}}Email</a>
<a href="/settings/tracking" {{if eq .Nav "settings/tracking"}}aria-current="page"{{end}}>{{template "icon" "metrics"}}Website &amp; sales</a>
<div class="nav-label">AI</div>
<a href="/settings/ai" {{if eq .Nav "settings/ai"}}aria-current="page"{{end}}>{{template "icon" "ai"}}AI</a>
</nav>
+1 -1
View File
@@ -12,7 +12,7 @@
{{else if .NotReady}}<p class="warn-text">Sending is off: {{.NotReady}}.</p>
{{else}}
<p><strong>{{.SentToday}}</strong> of {{.S.DailyLimit}} emails sent today{{with .Counts.queued}}, <strong>{{.}}</strong> queued{{end}}. {{if .Window}}Paused: {{.Window}}.{{else}}Sending now, one every {{.S.GapMinutes}} minutes or more.{{end}}</p>
{{with .LastCheck}}<p class="small muted">Inbox read {{ago .At}}{{if .Error}}: <span class="error-text">{{.Error}}</span>{{else}}: {{.Read}} new {{if eq .Read 1}}message{{else}}messages{{end}}{{if .Replies}}, {{.Replies}} {{if eq .Replies 1}}reply{{else}}replies{{end}}{{end}}{{if .Bounces}}, {{.Bounces}} bounced{{end}}{{if .Stops}}, {{.Stops}} asked to stop{{end}}{{if .AutoReplies}}, {{.AutoReplies}} automatic{{end}}.{{end}}</p>{{end}}
{{with .LastCheck}}<p class="small muted">Inbox read {{ago .At}}{{if .Error}}: <span class="error-text">{{.Error}}</span>{{else}}: {{.Read}} new {{if eq .Read 1}}message{{else}}messages{{end}}{{if .Replies}}, {{.Replies}} {{if eq .Replies 1}}reply{{else}}replies{{end}}{{end}}{{if .Bounces}}, {{.Bounces}} bounced{{end}}{{if .Stops}}, {{.Stops}} asked to stop{{end}}{{if .AutoReplies}}, {{.AutoReplies}} automatic{{end}}{{if .Bookings}}, {{.Bookings}} {{if eq .Bookings 1}}booking{{else}}bookings{{end}}{{end}}.{{end}}</p>{{end}}
{{end}}
</section>
+2 -1
View File
@@ -79,7 +79,8 @@
<label>Address <input name="website_url" type="url" value="{{.URL}}" placeholder="https://"></label>
<label>Hugo repository on Gitea <input name="website_repo" value="{{.Repo}}" placeholder="https://gitea.example.com/org/site.git"></label>
<label>Branch that gets published <input name="website_branch" value="{{.Branch}}" placeholder="main"></label>
<label>Plausible site <input name="website_plausible" value="{{.PlausibleSite}}" placeholder="example.com"></label>
<label>Plausible site <input name="website_plausible" value="{{.PlausibleSite}}" placeholder="example.com">
<span class="help">The site's name in Plausible, usually its domain. Leave it empty if that's the website's domain.</span></label>
<label>Google Search Console property <input name="website_gsc" value="{{.SearchConsoleProperty}}" placeholder="sc-domain:example.com"></label>
<label>Bing Webmaster site <input name="website_bing" value="{{.BingSite}}" placeholder="https://example.com/"></label>
</div>
+11 -1
View File
@@ -60,7 +60,7 @@
</div>
<label>Hypothesis <textarea name="hypothesis" rows="2" placeholder="Teams complaining about the Microsoft 365 price rise switch within a quarter.">{{$s.Hypothesis}}</textarea></label>
<label>How to spot it <textarea name="spot" rows="4" placeholder="One per line: search queries, keywords, origami.chat or explee.com criteria">{{$s.Spot}}</textarea>
<span class="help">Discovery (next) runs these as searches, so write them the way you'd search for the companies.</span></label>
<span class="help">Finding companies runs these as searches, so write them the way you'd search for the companies.</span></label>
<label>Angle <textarea name="angle" rows="3" placeholder="The pain, and what we promise about it">{{$s.Angle}}</textarea>
<span class="help">What emails, LinkedIn messages and content for this signal should say.</span></label>
<div class="cols">
@@ -87,6 +87,16 @@
<div class="small">{{range $k, $v := .Stats}}{{if $v}}<span class="stat">{{$k}}: <strong>{{$v}}</strong></span> {{end}}{{end}}</div></li>{{end}}</ul>
{{end}}
<h2>Content for it</h2>
{{if .Posts}}
<ul class="items">{{range .Posts}}<li class="item"><span class="badge {{if eq .Status "published"}}published{{else}}draft{{end}}">{{.Status}}</span> {{.Channel}} · {{truncate 140 .Content}}
<span class="muted small">{{if not .PublishedAt.IsZero}}published {{ago .PublishedAt}}{{with .PostURL}} · <a href="{{.}}" target="_blank" rel="noopener noreferrer">view</a>{{end}}{{else}}written {{ago .CreatedAt}}{{end}}</span></li>{{end}}</ul>
{{else}}<p class="help">No posts written for it yet. On <a href="/content">Content</a>, pick items and choose this signal under “For a buying signal”.</p>{{end}}
{{with .Links}}
<p class="small">Links tagged with it, for landing pages, the shopping cart, or a link you share by hand (add <code>utm_source</code> and <code>utm_medium</code> for where you put it). Visits on them count for this signal:</p>
<ul class="small">{{range $i, $u := .}}<li><code id="link-{{$i}}">{{$u}}</code> <button type="button" class="link small" data-copy="link-{{$i}}">Copy</button></li>{{end}}</ul>
{{end}}
{{if .Events}}
<h2>Latest steps</h2>
<table class="list">
+68
View File
@@ -0,0 +1,68 @@
{{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}}