<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://insights.klusai.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://insights.klusai.com/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-08-09T18:53:40+00:00</updated><id>https://insights.klusai.com/feed.xml</id><title type="html">KlusAI Insights</title><subtitle>What we learned building kOS, its verticals and the models behind them. Written from the code, the incidents and the measurements, not from the outside looking in.</subtitle><author><name>KlusAI</name><email>hello@klusai.com</email></author><entry><title type="html">Four sites, one tracker id, and three dashboards that said Setup pending</title><link href="https://insights.klusai.com/kos/observability/2026/08/09/four-sites-one-tracker-id.html" rel="alternate" type="text/html" title="Four sites, one tracker id, and three dashboards that said Setup pending" /><published>2026-08-09T00:00:00+00:00</published><updated>2026-08-09T00:00:00+00:00</updated><id>https://insights.klusai.com/kos/observability/2026/08/09/four-sites-one-tracker-id</id><content type="html" xml:base="https://insights.klusai.com/kos/observability/2026/08/09/four-sites-one-tracker-id.html"><![CDATA[<p>kOS serves four public sites from one Django application: the company site, two
vertical products, and our compute property. One codebase, one deployment, four
domains resolved by host at request time.</p>

<p>Analytics was a single setting.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">PLAUSIBLE_SCRIPT_ID</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">environ</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">"PLAUSIBLE_SCRIPT_ID"</span><span class="p">,</span> <span class="s">""</span><span class="p">)</span>
</code></pre></div></div>

<p>Every page on every host rendered that one id. So three of the four sites
reported their pageviews into the fourth’s dashboard, and their own dashboards
sat at zero, showing the analytics provider’s cheerful <strong>Setup pending</strong> badge
for months.</p>

<h2 id="why-nobody-noticed">Why nobody noticed</h2>

<p>Because the failure looks exactly like the thing you would expect to see anyway.</p>

<p>A new product subdomain with no traffic is unremarkable. “Setup pending” reads
as <em>you have not finished wiring this up yet</em>, which was true at some point and
so never got questioned. Meanwhile the company site’s numbers went <strong>up</strong>, and
nobody investigates numbers going up.</p>

<p>The tracker was installed correctly, firing correctly, and reporting correctly.
It was reporting to the wrong place, and there is no error for that.</p>

<h2 id="the-fix-and-the-part-worth-arguing-about">The fix, and the part worth arguing about</h2>

<p>The id now resolves per request hostname:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">PLAUSIBLE_SCRIPT_IDS</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">"klusai.com"</span><span class="p">:</span> <span class="s">"..."</span><span class="p">,</span>
    <span class="s">"lex.klusai.com"</span><span class="p">:</span> <span class="s">"..."</span><span class="p">,</span>
    <span class="s">"med.klusai.com"</span><span class="p">:</span> <span class="s">"..."</span><span class="p">,</span>
    <span class="s">"razorbridge.eu"</span><span class="p">:</span> <span class="s">"..."</span><span class="p">,</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Hostname, deliberately, and not the internal notion of which product a request
belongs to. Our architecture separates a <em>vertical</em> (a brand-neutral capability
like legal or healthcare) from a <em>deployment profile</em> (the per-host brand and
storefront). Several hosts can share a vertical. An analytics property is a
domain. Key it by the thing it actually is.</p>

<p>The argument worth having is about the fallback. The obvious design is for an
unrecognised host to fall back to the main site’s id, so tracking never silently
stops. That is precisely the bug: it is how three products’ traffic ended up
somewhere else, and the failure is invisible because the numbers still look
plausible.</p>

<p>An unmapped host now gets <strong>no tracker at all</strong>. An empty dashboard is a
question somebody eventually asks. Contaminated numbers are a decision somebody
eventually makes.</p>

<p>A test reads the deployment-profile registry against the id map and fails if a
public host has no analytics property, so the next product cannot launch into
the same hole.</p>

<h2 id="two-things-this-generalises-to">Two things this generalises to</h2>

<p><strong>Config that is global in a multi-tenant app is a claim that the thing is
global.</strong> Every setting the request path touches deserves the question: is this
per deployment, or per instance? Ours was in the wrong bucket for months and
nothing complained, because nothing could.</p>

<p><strong>A fallback is a decision to be wrong quietly.</strong> Falling back is right when the
degraded state is visible and harmless. When the degraded state is <em>plausible
data</em>, failing closed is kinder to the people who will read it later.</p>

<p>There is a postscript. Fixing the split let us look properly, and we found the
company site had recorded nothing at all for five months on a lapsed
subscription. The tracker was firing the whole time. Two different ways to have
no data, both of which look like a quiet quarter.</p>

<hr />

<p>Building something in a regulated European industry and want it in production
rather than in a slide?
<a href="https://klusai.com/contact/?intent=scoping-session">Book a use-case scoping session</a>.</p>]]></content><author><name>KlusAI</name><email>hello@klusai.com</email></author><category term="kos" /><category term="observability" /><summary type="html"><![CDATA[One Django app serves four public sites. All four shipped the same analytics tracker id, so three products filed their traffic under a fourth, and the fix was less interesting than the reason we could not see it.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://insights.klusai.com/assets/og-insights.png" /><media:content medium="image" url="https://insights.klusai.com/assets/og-insights.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>