virling Pricing Self-host Demo Changelog Agencies GitHub Start free trial
blog / 2026-11-24

Server-side revenue tracking without a tag manager

By Devendra Variya, co-founder of Virling. Published 2026-11-24, updated 2026-11-29.

Server-side revenue tracking means a sale is counted by a server, not by a script on the thank-you page. There are two ways to do it without a tag manager. Your server can send a purchase event when the payment provider confirms a payment, or your analytics can read payments from the provider itself. Both need one thing from your code: at checkout, read the visitor ID cookie on the server and put it on the payment, so the sale can be matched to a visit. Reading payments also covers refunds and renewals with no events to send.

Browser event, server event or payments from the provider

What to compareBrowser eventServer eventPayments read from the provider
What reports the saleA script on the thank-you pageYour code, usually in a payment webhook handlerThe provider's own records
Buyer closes the tab after payingThe sale is missedCountedCounted
Sale is counted twice whenThe thank-you page is reloaded and nothing removes the duplicateA webhook is delivered again and your handler does not check for itNot expected: each payment is stored once, under its payment ID
Refunds and renewalsNo page is open, so nothing is sentOne more event for each, which you writeRead with the payments
Amount and currencyWhatever the page sendsWhatever your code sendsWhat was charged
What you maintainA tag and its triggerA handler, its retries and one event per caseA key, and the visitor ID at checkout
What links it to a channelThe browser's cookieAn ID you saved at checkoutAn ID you saved at checkout

The last row is the one that is easy to miss. Moving the event to a server makes the total better, but a server does not know which visit the buyer came from unless checkout carried an ID.

Where a tag manager's server container fits

In the usual setup, the browser still sends the event, to a container on your own subdomain, and the container forwards it. That changes where the event goes, not what starts it: a thank-you page that never loads still sends nothing, and a renewal has no page. If you only need a script on every page, Google Tag Manager revenue tracking covers the ordinary container.

Read the visitor ID cookie on your server

The Virling script sets a first-party cookie, virling_vid, on your registrable domain, so your backend receives it with requests from the browser. Read it on the request that creates the checkout:

  • Not in the webhook handler. That request comes from the payment provider and has none of the buyer's cookies.
  • On the same domain. Subdomains such as app.example.com share the cookie. A backend on another domain does not get it, so send window.virling?.vid?.() from the page in the request body.
  • With credentials. A fetch from www.example.com to api.example.com is cross-origin, so add credentials: "include" and allow credentials in the API's CORS headers.
  • Expect it to be missing. Create the checkout anyway. The payment still counts, as Unattributed.

Node

With Express, cookie-parser and the stripe package:

import express from "express";
import cookieParser from "cookie-parser";
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
const app = express();
app.use(cookieParser());

app.post("/checkout", async (req, res) => {
  const session = await stripe.checkout.sessions.create({
    client_reference_id: req.cookies.virling_vid,
    line_items: [{ price: "price_...", quantity: 1 }],
    mode: "subscription",
    success_url: "https://yourdomain.com/thanks",
  });
  res.redirect(303, session.url);
});

Python

With Flask and the stripe library:

import os

import stripe
from flask import Flask, redirect, request

app = Flask(__name__)
stripe.api_key = os.environ["STRIPE_SECRET_KEY"]


@app.post("/checkout")
def checkout():
    params = {
        "line_items": [{"price": "price_...", "quantity": 1}],
        "mode": "subscription",
        "success_url": "https://yourdomain.com/thanks",
    }
    vid = request.cookies.get("virling_vid")
    if vid:
        params["client_reference_id"] = vid

    session = stripe.checkout.Session.create(**params)
    return redirect(session.url, code=303)

Your own payment form

If you create a PaymentIntent yourself, there is no client_reference_id, so use metadata. In Node:

const intent = await stripe.paymentIntents.create({
  amount: 4900,
  currency: "usd",
  metadata: { virling_vid: req.cookies.virling_vid },
});

In Python:

vid = request.cookies.get("virling_vid")
intent = stripe.PaymentIntent.create(
    amount=4900,
    currency="usd",
    metadata={"virling_vid": vid} if vid else {},
)

The amount is an example. If client_reference_id already holds your own ID, put the visitor ID in the Checkout Session's metadata.virling_vid instead: Stripe client_reference_id explains the field and its limits, and Stripe Checkout UTM parameters shows how to keep the tags in Stripe as well. On .NET, ASP.NET Core Stripe UTM tracking reads the cookie and creates the session in a minimal API with Stripe.net. For Paddle, Polar, LemonSqueezy, Dodo Payments, Creem, RevenueCat, WooCommerce and Shopify, the checkout snippet generator writes the code, and the checkout docs say which field Virling reads.

How the payment finds its visit

There is no purchase event to send. You connect your provider with a key, and for Stripe that is a restricted key that can only read. Virling asks the provider for new payments once a minute, takes the visitor ID from each one, and credits the payment to one of that visitor's visits inside the lookback window, 90 days by default. LemonSqueezy, Creem and RevenueCat also send a webhook, which Virling adds for you when you connect.

On Stripe you can check it with a test key: pay once from a page that runs the script, wait for the next sync, and open the payments list. The payment should show a channel. The steps are in the Stripe docs.

Start free trial

Refunds without an event

A refund belongs to a payment that is already there. When Virling reads it, it lowers that payment's revenue, on the payment's own date, and the channel that was credited loses the same amount. How soon a later refund shows up depends on the provider:

  • Stripe: a refund made after you connect counts even when the charge is older than 90 days, and a dispute that closes as lost after you connect counts as refunded.
  • Paddle, WooCommerce, LemonSqueezy and Creem: payments from the last 60 days are read again every 6 hours. A refund on an older one is not picked up automatically.
  • RevenueCat: a refund event marks the whole purchase refunded, and partial refunds are not handled separately.

The page for each provider in the payments docs has the rest.

Renewals without an event

A renewal has no visit and no browser, so there is no cookie to read. It takes the attribution of the customer's first payment instead: the earliest payment that did not fail, from the same provider, matched by the provider's customer ID. On Stripe, a charge is a renewal when its invoice has the billing reason subscription_cycle, and plan changes with subscription_update keep the first payment's channel too.

Two limits follow from that. The first payment has to be in Virling, and payments older than the 90-day import, 60 days on Shopify, are not. And a payment without a customer ID cannot be linked to a first payment. The rule for every provider, and for free trials, is in the renewals docs.

Example

Made-up numbers for one imaginary customer. They arrive from a newsletter, subscribe at $40 a month, renew twice, and get the last month refunded in full.

MethodRevenue recorded
Browser event$40, if the thank-you page loads
Server event for the first checkout only$40
Server events for checkout and renewals, none for refunds$120
Server events for all three$80
Payments read from the provider$80

With the visitor ID on the first checkout, the $80 is credited to the newsletter.

What server-side tracking does not fix

  • Visits that were never recorded. The visit still starts in the browser. If an ad blocker stops the script, the payment is counted with no channel.
  • Cookies the buyer declined. In cookieless mode, or before consent, there is no visitor ID to read. Moving the sale to a server does not settle whether you need consent. Privacy and consent lists what each mode stores.
  • A second device. A cookie from a phone is not on the laptop that pays.
  • Links opened elsewhere. A payment link in an email or a QR code never passes through your server or your page, so it carries no ID.
  • Missing sources. A visit with no referrer and no UTM tags is Direct, wherever the sale was counted.
  • History. Payments from before the script was installed count as revenue and stay Unattributed.
  • The choice of model. Which of several visits gets the credit is still a setting you pick.

When checkout cannot carry the ID, a Stripe, Shopify or WooCommerce payment can be matched by email instead.

If you do send server events

Some tools take no other input, such as an ad platform's conversion API. Then:

  1. Send from the provider's webhook, after checking its signature, not from the route the buyer returns to.
  2. Handle the same event twice without sending twice. Stripe says an endpoint might receive an event more than once (Stripe webhook docs).
  3. Send the payment ID with the event, so the receiving tool can drop duplicates if it supports that.
  4. Write separate events for renewals and refunds.
  5. Compare a finished month with the provider's own total.

Frequently asked questions

What is server-side revenue tracking?

It is counting sales from your server or from your payment provider instead of from the buyer's browser. Either your server sends a purchase event when the provider confirms a payment, or a tool reads the payments from the provider. The second way needs no events from you.

Do I need a server-side tag manager to track revenue?

No. A tag manager's server container forwards events that something else sends to it. If your checkout carries a visitor ID and your analytics reads payments from the provider, there is no purchase event to forward.

Does server-side tracking get around ad blockers?

Only for the payment. A blocker cannot stop your server or your provider, so the sale is counted. The visit is still recorded in the browser, and when that is blocked the payment has no channel to be credited to.

Does server-side tracking remove the need for consent?

Do not assume so. The visitor ID still comes from a cookie in the buyer's browser, and whether you need consent depends on where your visitors live and how you use the data. This is not legal advice.

Can I read the visitor ID in a payment webhook?

Not from a cookie. The webhook request comes from the provider's servers, so it carries none of the buyer's cookies. Read the cookie on the request that creates the checkout and put the ID on the checkout.

How are refunds and renewals tracked server-side?

With events, you send one for each refund and each renewal. With payments read from the provider, the refund lowers the payment it belongs to, and a renewal takes the channel of the customer's first payment.

Count revenue from the payment, and see the visit behind it

Virling is open source under AGPL. Self-host it free, or use the hosted version with a 14-day free trial. It connects to Stripe, Paddle, Shopify, WooCommerce, Polar, LemonSqueezy, Dodo, Creem and RevenueCat.

Start free trial See the demo