We Were Losing Ad Conversions to Our Own Performance Optimization

When you optimize for page speed, you can accidentally break the thing you were trying to protect. That is what happened to our own Google Ads and TikTok conversion tracking, and we only caught it by reading our own code the way we would read a client's. A few weeks ago we deferred gtag.js and the TikTok pixel to requestIdleCallback, so they would not compete with page hydration on slow mobile connections, where most of our traffic lives. It is a common performance move and it worked: fewer render-blocking scripts, faster interactivity. It also quietly broke conversion tracking. Both snippets only send their actual network beacon once the deferred script loads and flushes a queue of events. That queue is fine for someone who keeps browsing, because the idle callback eventually fires somewhere on the site. It is not fine for someone who registers in a few seconds and immediately closes the tab, which is exactly what a lot of ad traffic looks like, especially from in-app browsers on TikTok and Meta. The TikTok pixel had it worse: its tracking object was not even defined until the idle callback ran, so calls made before that were not queued — they were just dropped. The fix was to stop deferring the two scripts that conversions depend on. Both load as async anyway, so there was no real first-paint cost to begin with — only a theoretical one we never should have paid for at the price of losing the exact events that justify the ad spend. The lesson we are taking into the next optimization pass: anything downstream of a one-time, fast-exit event (signup, purchase, install) should be treated as latency-sensitive, full stop. Everything else can wait for idle.