惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
P
Palo Alto Networks Blog
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
J
Java Code Geeks
博客园_首页
Scott Helme
Scott Helme
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
V
Visual Studio Blog
Cloudbric
Cloudbric
Jina AI
Jina AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
The Last Watchdog
The Last Watchdog
SecWiki News
SecWiki News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
W
WeLiveSecurity
K
Kaspersky official blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hacker News: Ask HN
Hacker News: Ask HN
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
量子位
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 三生石上(FineUI控件)
Recent Commits to openclaw:main
Recent Commits to openclaw:main

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Stop Sending Plan Price to GA4 as Conversion Value (And Why Your gtag Is Lying to You Anyway)
Nicolas Flor · 2026-05-14 · via DEV Community

TL;DR

If you're a SaaS founder running Google Ads with Smart Bidding, and your conversion event sends the nominal plan price as value, you're optimizing Google's algorithm for the wrong outcome. You're paying it to find people who start trials, not people who pay.

Also: your frontend gtag event is silently dropped in ~30% of sessions due to ad-blockers, Safari ITP, and consent-mode rejections. Smart Bidding sees a fraction of reality.

The fix is two changes:

  1. Conversion value = expected LTV × conversion probability, not sticker price.
  2. Send events server-side via Measurement Protocol, not from the browser. Here's the .NET 10 + GA4 implementation that's running in production at NeoJurídico.

Why this matters more than people realize

Smart Bidding is a value-optimization auction. You tell Google "this conversion was worth $X", and Google bids for users it predicts will produce similar X-valued events.

If you pass value: 50000 (your monthly plan price in COP) every time a user starts a free trial, Google learns: "find me more trial-starters." It will happily burn your ads budget acquiring people who tick the trial box and never pay.

What you actually want Google to optimize for is revenue you will collect. That number is not the plan price. It's the plan price discounted by:

We pass value = plan.Price × 0.36. The 0.36 is trial→paid conversion rate × expected months retained / refund adjustment. Yours will be different. Calculate it from your data; don't copy mine.


Why client-side gtag is a partial-coverage liability

The default GA4 setup ships an event from the browser:

gtag('event', 'trial_started', {
  value: 50000,
  currency: 'COP',
  transaction_id: 'sub_146'
});

Enter fullscreen mode Exit fullscreen mode

This event has multiple failure modes before it reaches Google:

Failure Approximate loss
uBlock Origin, AdBlock, Brave Shields blocking googletagmanager.com 15–25%
Safari ITP capping cookie lifetime + cross-site restrictions 5–10%
Consent Mode V2 set to denied (EU/UK + several US states) varies, 10–40% in some regions
User closes tab before script fires (especially after success-page redirect from MercadoPago/Stripe) 1–3%
Mobile browsers killing JS context on backgrounding 1–2%

Realistic combined loss for a LATAM SaaS audience: 20–35% of conversions never make it to GA4 client-side. Smart Bidding is optimizing against a 65–80% sample of your real funnel — and that sample is biased (privacy-conscious users underrepresented).

Worse: this loss compounds with the 6–18 hour ingestion lag when conversions are imported from GA4 to Google Ads. Smart Bidding sees an incomplete picture, late.

Server-side via Measurement Protocol fixes both: 100% delivery (you control the network call), and you can mirror to Google Ads' offline conversion API in the same request to skip the lag.


The architecture

The flow that produces a high-confidence revenue event:

[Browser]  →  signup form → POST /api/auth/signup
[.NET API]
   │
   ├─ Persist user + subscription (Status: Pending, AwaitingTrialCheckout)
   │
   ├─ If campaign user + trial flow:
   │     └─ Redirect frontend to /checkout (collect card upfront)
   │
   ├─ After card tokenization succeeds + MP preapproval created:
   │     ├─ subscription.Status = "Open"
   │     ├─ subscription.TrialEndDate = now + 14d
   │     └─ Fire-and-forget: _ga4.TrackTrialStartedAsync(...)
   │           │
   │           └─ POST https://www.google-analytics.com/mp/collect
   │                 (Measurement Protocol — server to Google)
   │
   └─ Return 200 to frontend

Enter fullscreen mode Exit fullscreen mode

The key property: the GA4 event fires from the API, not the browser. Whether the user has uBlock installed, whether their Brave Shields are nuclear, whether they closed the tab the millisecond MercadoPago redirected back — irrelevant. The event already shipped from our server.


The .NET 10 implementation

A minimal Ga4MeasurementProtocolService:

public sealed class Ga4MeasurementProtocolService : IGa4Service
{
    private readonly HttpClient _http;
    private readonly Ga4Options _opts;
    private readonly ILogger<Ga4MeasurementProtocolService> _logger;

    public Ga4MeasurementProtocolService(
        HttpClient http,
        IOptions<Ga4Options> opts,
        ILogger<Ga4MeasurementProtocolService> logger)
    {
        _http = http;
        _opts = opts.Value;
        _logger = logger;
    }

    public async Task TrackTrialStartedAsync(
        int userId,
        string planName,
        decimal expectedValue,
        string currency,
        int trialDays,
        CancellationToken ct)
    {
        // client_id: must be stable per user. We hash the user id with a salt
        // so we can correlate without leaking the raw id to Google.
        var clientId = HashClientId(userId);

        var payload = new
        {
            client_id = clientId,
            user_id = userId.ToString(),  // GA4 user-id, for cross-device stitching
            timestamp_micros = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 1000,
            non_personalized_ads = false,
            events = new[]
            {
                new
                {
                    name = "trial_started",
                    @params = new Dictionary<string, object>
                    {
                        ["value"] = expectedValue,         // NOT plan.Price
                        ["currency"] = currency,
                        ["plan_name"] = planName,
                        ["trial_days"] = trialDays,
                        ["engagement_time_msec"] = 100,    // GA4 requires this
                        ["session_id"] = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
                    }
                }
            }
        };

        var url = $"https://www.google-analytics.com/mp/collect" +
                  $"?measurement_id={_opts.MeasurementId}" +
                  $"&api_secret={_opts.ApiSecret}";

        try
        {
            using var resp = await _http.PostAsJsonAsync(url, payload, ct);
            if (!resp.IsSuccessStatusCode)
            {
                _logger.LogWarning(
                    "GA4 MP returned {Status} for user {UserId}",
                    resp.StatusCode, userId);
            }
        }
        catch (Exception ex)
        {
            // Never let analytics failures break the user flow.
            _logger.LogError(ex, "GA4 MP call failed for user {UserId}", userId);
        }
    }

    private string HashClientId(int userId)
    {
        using var sha = SHA256.Create();
        var bytes = Encoding.UTF8.GetBytes($"{_opts.ClientIdSalt}:{userId}");
        return Convert.ToHexString(sha.ComputeHash(bytes))[..16].ToLowerInvariant();
    }
}

Enter fullscreen mode Exit fullscreen mode

Registration in Program.cs:

builder.Services.Configure<Ga4Options>(
    builder.Configuration.GetSection("Ga4"));

builder.Services.AddHttpClient<IGa4Service, Ga4MeasurementProtocolService>()
    .SetHandlerLifetime(TimeSpan.FromMinutes(5))
    .AddPolicyHandler(GetRetryPolicy());  // Polly retry, optional

Enter fullscreen mode Exit fullscreen mode

Call site, inside SubscriptionsService.ActivateSubscriptionAsync after the status flips to Open:

if (_ga4 != null && s.Status == "Open" && hasCampaign && hasTrial)
{
    var expectedValue = Math.Round(plan.Price * 0.36m, 0);

    // Fire and forget — do not await on the request path
    _ = _ga4.TrackTrialStartedAsync(
        userId,
        plan.Name,
        expectedValue,
        "COP",
        trialDays.Value,
        CancellationToken.None);
}

Enter fullscreen mode Exit fullscreen mode

Two things to note:

  1. Fire-and-forget. Analytics latency must never block the user response. If GA4 is slow or down, the user still gets their dashboard.
  2. CancellationToken.None intentionally. If the request token cancels (user closed the tab), we still want the event to ship. For a production-grade version you'd want this enqueued to a background channel (System.Threading.Channels) with a hosted service draining it, so HTTP failures and retries don't pile up on the request thread. Skipped here for brevity.

The conversion-value calculation

This is where most posts wave their hands. The 0.36 factor isn't arbitrary; here's how to derive yours.

Pull these from your DB or analytics:

WITH trials AS (
  SELECT id, plan_id, created_at, trial_end_date, status
  FROM user_subscriptions
  WHERE created_at BETWEEN '2025-01-01' AND '2025-12-31'
    AND trial_end_date IS NOT NULL
),
outcomes AS (
  SELECT
    t.id,
    t.plan_id,
    CASE
      WHEN t.status = 'Open' AND EXISTS (
        SELECT 1 FROM payments p
        WHERE p.subscription_id = t.id
          AND p.amount > 0
          AND p.created_at > t.trial_end_date
      ) THEN 1 ELSE 0
    END AS converted,
    (SELECT COUNT(*) FROM payments p
     WHERE p.subscription_id = t.id AND p.status = 'approved')
      AS cycles_paid
  FROM trials t
)
SELECT
  AVG(converted)                              AS trial_to_paid_rate,
  AVG(CASE WHEN converted = 1 THEN cycles_paid END) AS avg_cycles_when_paid,
  AVG(cycles_paid)                            AS avg_cycles_overall
FROM outcomes;

Enter fullscreen mode Exit fullscreen mode

Now compute:

expected_value_factor = trial_to_paid_rate
                      × avg_cycles_when_paid
                      × (1 - refund_rate)

Enter fullscreen mode Exit fullscreen mode

For NeoJurídico with our first real cohort:

  • trial→paid rate: ~0.45 (post-fix; was 0 before)
  • avg cycles when paid: ~0.85 (most users still in early months)
  • refund rate: ~0.06 0.45 × 0.85 × 0.94 ≈ 0.36

Recalculate this quarterly. The factor will move as your retention curves mature.


What you actually see in Google Ads after switching

Three signals to monitor in the first 30 days:

1. Reported conversion count goes up by 20–35%. Not because you're getting more conversions — because you're finally capturing the ones ad-blockers were eating. Don't panic and don't celebrate. This is just measurement honesty.

2. tCPA and tROAS recommendations from Google shift. With more accurate (and lower-magnitude) conversion values, Google's recommended targets become realistic. The phantom "this conversion was worth $50,000" signal goes away.

3. Smart Bidding starts choosing different audiences. This is the actual ROI. Trial-tourists drop, payment-likely segments get bid up. Expect 2–4 weeks for the algorithm to re-learn — Google needs ~30 conversions on the new value signal before the model meaningfully updates.

Important caveat for small SaaS: GA4 data-driven attribution requires 400+ monthly conversions before it activates. If you're below that, GA4 silently falls back to last-click attribution regardless of your configuration. Below this volume, importing conversions into Google Ads as a primary source is mostly cargo-culting — go straight to Google Ads' own conversion API alongside GA4 if you need the bidding signal.


Mistakes to avoid

Don't double-count. If you keep client-side gtag('event', 'trial_started') AND fire server-side, GA4 will receive the same event twice with different client_ids. Pick one. Server-side wins.

Don't send PII in user_id or event parameters. Hash internal IDs. Never put emails, phone numbers, or names in MP payloads — it violates GA4 TOS and will eventually get your property suspended.

Don't set non_personalized_ads: true by default. This silently kills the event's usefulness for Smart Bidding signal. Only set it true when you genuinely don't have consent for personalization.

Don't fire on Pending status. We only fire when the subscription transitions to Open AND has a payment method. Firing on Pending (or worse, on signup) gives you back the same garbage signal you had before — Smart Bidding will optimize for users who get to the checkout page.

Don't forget about offline conversion uploads. For high-confidence revenue events (first paid charge after trial), you should also upload to Google Ads' offline conversion API with the original gclid. That's the cleanest possible signal — actual paid revenue tied to the click that started it. The GA4 event is for measurement; the offline conversion is for bidding. Different jobs.


What this changes for the next 30 days

Combined with the trial-flow fix from the previous post, we now have:

  • A trial flow that can actually convert (card upfront, deferred first charge)
  • A measurement pipeline that captures conversions reliably regardless of client environment
  • A conversion value signal that reflects expected revenue, not plan price If trial→paid lands anywhere near our 0.45 projection in the next cohort, the Ads campaigns should start producing positive ROAS within the second 30-day window as Smart Bidding re-learns.

I'll post the numbers when they're in.


Takeaways

  1. Conversion value ≠ plan price. Pass expected_LTV × conversion_probability. For SaaS without much LTV data yet, use plan.Price × trial→paid_rate as a floor.
  2. Client-side gtag is unreliable in 2026. Privacy controls, ad-blockers, and consent mode V2 silently delete 20–35% of events. Server-side via Measurement Protocol is the only path to high-confidence revenue tracking.
  3. Fire on real state transitions, not on form submissions. Status becoming Open after card tokenization is a high-confidence event. Anything earlier in the funnel is speculation.
  4. For small SaaS (<400 conversions/month), don't rely on GA4 import as your Smart Bidding source. Use Google Ads' own conversion API alongside GA4 — or you're paying for the latency of GA4 import without getting data-driven attribution in return. The plumbing here isn't glamorous, but the difference between Smart Bidding optimizing for trial-tourists and Smart Bidding optimizing for paying customers is measured in months of burned ad spend. Worth getting right early.

I work on NeoJurídico, a court-process monitoring platform for Colombian lawyers. The full SaaS billing stack is .NET 10 + EF Core + PostgreSQL + MercadoPago. If you're building LATAM SaaS and hitting similar gotchas, my DMs are open.