viakite
Dashboard

Guides/Use cases/Online stores and payments

Online stores and payments

Revenue by source, in any currency, and the path to purchase

You sell things online: a store, digital products, courses, bookings. You want revenue next to the visitors who brought it, by channel and campaign, in every currency you sell in, and the steps where shoppers give up.

Who it's for

Online stores, sellers of digital products and courses, and any site that takes payments.

What you get

FeatureWhat it answersGuide
Revenue on eventsMoney per event, the average order value, revenue over timeRevenue
Payment providersRevenue straight from Stripe, Razorpay or Dodo Payments, tied to the visitPayment providers
Several currenciesEvery sale converted to your project's currency at the day's rateSeveral currencies
Revenue by sourceWhich channel, campaign or site brought the buyersRevenue
FunnelsWhere shoppers drop off between product and paymentFunnels
GoalsPurchases as conversions, with their revenueGoals
Server-side eventsOrders sent from your backend, which nothing in the browser can blockServer-side events

Set it up

  1. Install it

    Add the snippet from Analytics → Install to every page. The Install screen has snippets for Shopify, WordPress and Webflow as well as the frameworks (Install Analytics).

  2. Send the shopping steps

    src/shop.ts
    1import { track } from "@viakite/sdk";
    2
    3track("Product viewed", { product: "Pro yearly" });
    4track("Add to cart", { product: "Pro yearly" });
    5track("Checkout started");
  3. Send each purchase once, from your server

    Send the order when it is paid, from the handler that confirms it. Give it the order id as the event id, so a retry is stored once:

    src/orders.ts
    1import { Viakite } from "@viakite/node";
    2
    3const viakite = new Viakite({ secretKey: process.env.VIAKITE_SECRET_KEY!, project: "prj_…" });
    4
    5export function orderPaid(order: Order, req: Request) {
    6 viakite.track(
    7 "Purchase",
    8 { revenue: order.total / 100, currency: order.currency, items: order.items.length },
    9 { id: order.id, userId: order.customerId, ip: req.ip, userAgent: req.headers["user-agent"] },
    10 );
    11}

    order.total / 100 turns cents or paise into the main unit. Passing the buyer's ip and userAgent ties the purchase to their visit and its source. On a thank-you page in the browser, the same call is track("Purchase", { revenue: 499, currency: "INR" }).

  4. Or let your payment provider send it

    Taking payments with Stripe, Razorpay or Dodo Payments? Connect it in Settings → Payment providers instead, put viakite_user_id in each payment's metadata (notes on Razorpay), and call identify(user.id) on the pages buyers see. Each payment becomes a Payment event with its revenue. Full steps: Payment providers.

  5. Make a goal and a funnel

    In Analytics → Goals, add an event goal Purchase (or Payment from a provider): its row shows conversions, conversion rate and revenue. In Analytics → Funnels, make Product viewed → Add to cart → Checkout started → Purchase, and click a step's drop to see where those shoppers went instead.

Then open Analytics → Revenue for revenue, orders, average order value, revenue over time and revenue by source.

What to watch

  • Count each sale once. Not on page reloads, not on retries without an event id, and not from both your code and a connected provider.
  • Amounts in the main unit. 499 for ₹499 and 19.99 for $19.99. Revenue sent as text ("499") is dropped.
  • Currencies. Rates are the European Central Bank's daily rates, about 30 currencies. A currency without a rate (such as AED) is left out of revenue; convert those before you send them.
  • Anonymous shoppers last a day. A funnel counts a visitor who goes through every step within a day. For longer journeys, identify signed-in customers and count users (up to 30 days).
  • Provider payments need a recent visit. A payment is counted as revenue only when its viakite_user_id was seen in the 30 days before it.