Files
supermarket/internal/web/templates/tracking.html
T
davidandClaude Opus 5.5 e9871082b5 Phase 7 part 1: sign-ups by page
Settings → Website & sales says which clicked links count as a sign-up:
Supermarket suggests the sign-up, trial and checkout links visitors
clicked, and the user ticks, unticks or adds their own. The Plausible
import reads, per page a visit began on, the visitors, sign-ups and form
leads (a new page_days table); What ranks, the audit and Sites show
visits and sign-ups next to each page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:07:47 -07:00

94 lines
6.6 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 hx-disabled-elt="this" 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 hx-disabled-elt="this" 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>
{{if .PlausibleSet}}
<form method="post" action="/settings/tracking/signups" data-busy="Saving and reading the pages…">
<section class="card" id="signups">
<h3>What counts as a sign-up</h3>
<p class="small">Each page of your site is measured by what its visitors go on to do: click through to sign up, or send a form. Plausible records clicks on links to other sites (its <em>Outbound Link: Click</em> goal), and ties each to the page the visit began on. Say which of those links start a sign-up.{{if not .Signups.Saved}} <strong>Supermarket's suggestion is ticked</strong>: the links that look like a sign-up, a trial or a checkout. Change it and save to make it yours.{{end}}</p>
{{with .Links}}
<table class="list">
<thead><tr><th>A sign-up?</th><th>Link clicked, last 30 days</th><th class="num">Visitors</th></tr></thead>
<tbody>{{range .}}<tr>
<td><input type="checkbox" name="link" value="{{.URL}}" aria-label="{{.URL}} is a sign-up" {{if .Signup}}checked{{end}}></td>
<td class="small"><code>{{.URL}}</code></td><td class="num">{{num .Visitors}}</td>
</tr>{{end}}</tbody>
</table>
{{else}}<p class="help">No clicks on outbound links in the last 30 days, or Plausible couldn't be read.</p>{{end}}
<label>Other links that count (optional)
<textarea name="patterns" rows="3" placeholder="cloud.federated.computer/signup">{{.OwnPatterns}}</textarea>
<span class="help">One per line. A link counts if it contains the text, in any case: <code>/signup</code> counts every sign-up page on every site.</span>
</label>
<p class="small">Form leads count too, once your forms send Plausible's <code>Lead</code> goal (Sites → Lead forms).</p>
<div class="actions"><button type="submit">Save what counts</button></div>
{{template "last-run" .LastPages}}
</section>
</form>
{{end}}
{{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}}