Engineering
We Deleted 284 Lines to Track Signups Correctly
Our Ankik beta form hid true signup counts. We removed 284 lines, added clicks.page, and track register clicks with tests.
Our Ankik landing page collected emails but hid the truth. The beta form posted, the toast appeared, the thanks page rendered. I still could not answer one question. How many visitors clicked register this week?
This post records the Sep 24 change that fixed it. The commit is 59c2b45, PR 24, closes issue 23. Net change was +73 / -284 across 11 files.
What lightweight signup tracking means
Lightweight signup tracking means one script counts register clicks without a form backend. No custom toast code. No thanks page. No CSS for states you never test.
In our case, BaseLayout.astro loads https://clicks.page/t.js with defer and data-site. AnkikLayout.astro listens for clicks on a[href*="/register"] and calls window.clicks?.track("signup"). Three tests in analytics.test.ts lock that behavior.
Founders get a true count per day. Developers keep 58 lines instead of 284. Visitors get a faster page with no extra form round trip.
My first instinct was wrong
I first wanted to add more events to the existing form. I thought extra GA events would reveal the funnel. The form had validation, busy states, toast host, and a thanks page.
More code would have added more places to break. The form already owned 51 lines in BetaAccessForm.astro, 60 removed lines in AnkikLayout.astro, 27 lines in thanks.astro, and 143 lines in ankik.css. None of it answered the register click count. I deleted it instead.
What we removed
| File | Lines removed | Why |
|---|---|---|
src/components/ankik/BetaAccessForm.astro | 51 | Custom email post with manual states |
src/layouts/AnkikLayout.astro | 60 | Toast host, busy flags, submit handler |
src/pages/ankik/thanks.astro | 27 | Separate page after submit |
src/styles/ankik.css | 143 | Toast and form state styles |
src/lib/products/ankik.ts | 1 | Email reference for toast host |
Total removed was 284. Total added was 73. The page lost weight and gained truth.
What we added
Eleven lines in BaseLayout.astro load the script:
<script
is:inline
defer
src="https://clicks.page/t.js"
data-site={site.clicksSiteId}
></script>
is:inline keeps the exact HTML. defer keeps the page fast. data-site reads site.clicksSiteId value 4h2m0t2e6a1d from src/lib/site.ts.
One listener in AnkikLayout.astro records intent:
document.addEventListener("click", (event) => {
const link = event.target?.closest('a[href*="/register"]');
if (link) {
window.clicks?.track("signup");
}
});
No form submit. No fetch wrapper. A click on any register link counts.
How tests lock it
src/lib/analytics.test.ts has three tests. They read the real files, not mocks.
The first test checks config. It asserts site.clicksSiteId equals 4h2m0t2e6a1d.
The second test reads BaseLayout.astro. It asserts the script URL, the data-site binding, is:inline, and defer all exist.
The third test reads AnkikLayout.astro. It asserts the track("signup") call and the a[href*="/register"] selector both exist.
If someone removes the script or renames the selector, tests fail that day. That is the whole point.
What we kept and what we gave up
We kept GA and Clarity IDs in config that day. We did not claim a full migration in one commit. We added the lightweight path alongside and proved it with tests.
We gave up the custom toast UX and the thanks page. Register links now go direct. That removed states we never measured: busy label, wait spinner, inline error, toast timeout.
One edge remains. Ad blockers can stop the script. Direct server counts would catch that gap. For an MVP landing page, the click count is enough to compare weeks.
FAQ
Why keep the old form with GA events?
The form owned validation, toasts, and styles across four files. Each new event added another branch to test. The click listener needs one selector and one call.
Does defer delay signup counting?
No. defer loads the script after HTML parse but before user clicks matter. Clicks fire later. The count stays correct and the page stays fast.
How do I verify my own setup?
Open your layout file. Confirm the script URL, site ID, and defer. Click a register link and check the dashboard. Run your tests to lock the selector.
What if a link URL changes?
The selector targets /register in href. If routes change, the third test fails and points at the line. Update the selector and the test together.
Next step
If your beta form hides your signup count, delete it for a week. Ship one script and one listener. Compare true register clicks before you rebuild any form.
For related reading, see our Day 29 telemetry note and the proxy trust fix that stopped false 429s. To discuss your MVP analytics, contact us through the build sprint page.
OUR WORK

Book-Hotels-B2B
2026B2B travel agency platform with quote-to-invoice automation.

Ankik
2026Desktop-first accounting workspace for SMEs, 0 to launch.

Retainix
2025Multi-branch loyalty & cashback platform for petrol pumps & retail.
BOOK A CALL
Ready to turn your idea into a live product?
Schedule a 15-minute scoping call with Dhanji below. We'll discuss your scope, timeline, and tech strategy honestly.

