viakite
Dashboard

Guides/Use cases/Link-in-bio and creator platforms

Link-in-bio and creator platforms

Every profile tracked, each creator shown their own numbers

You run a platform where every user has a page: a link-in-bio profile, a creator page, a storefront, a portfolio. You want analytics for the whole platform, and you want to show each user their own numbers (views, visitors, which links they clicked) inside your product. Viakite counts everything with one install, and your backend reads each user's slice through the Query API.

Who it's for

Builders of link-in-bio tools, creator platforms and any product with one public page per user, who want per-user stats without building an analytics pipeline.

What you get

FeatureWhat it doesGuide
One installPage views, sources, countries and devices for every profileInstall Analytics
Custom events with propertiesProfile view and Link click, each carrying the profile_idCustom events
Allowed hostnamesProfiles on your subdomains (*.yourplatform.com) all count, nothing else doesTracking settings
The Query API with a secret keyAny report, filtered to one profile with props.profile_id, from your backendQueries
Rate limit headersHow many requests your key has left this secondAuthentication

Set it up

  1. Install once for the platform

    Add the snippet from Analytics → Install to the template every profile page uses, once:

    profile.html
    1<script defer src="https://us.api.vk.viabio.me/v1/a.js" data-project="pk_live_us_…"></script>

    If profiles live on subdomains, add *.yourplatform.com to the allowed hostnames in Analytics → Analytics settings → Tracking, so only your pages count. With a list set, profiles on creators' own domains need their hostnames added too, or their events are dropped.

  2. Tag each profile view

    When a profile page loads, send one event with the profile's id. Use your own id, never an e-mail address or a name a person could be found by:

    src/profile.ts
    1import { track } from "@viakite/sdk";
    2
    3track("Profile view", { profile_id: profile.id });

    With the script tag, call viakite.track("Profile view", { profile_id: "prf_8231" }).

    Page views arrive on their own as well. If every profile has its own path (/alice), you can also filter page views by page; the profile_id event works whatever the address is, custom domains included.

  3. Tag each link click

    Send an event when a link is clicked, with the profile and the link:

    src/links.ts
    1import { track } from "@viakite/sdk";
    2
    3track("Link click", { profile_id: profile.id, link_id: link.id });

    Or without JavaScript, with classes on the link (a space is written +):

    profile.html
    1<a href="https://youtube.com/@alice"
    2 class="viakite-event-name=Link+click viakite-event-profile_id=prf_8231 viakite-event-link_id=lnk_42">YouTube</a>

    Links to other sites also send the automatic Outbound link event, with the address clicked. Turn it off with data-outbound="false" if you only want Link click.

  4. Create a secret key for your backend

    In Settings → API keys, create a secret key with only the analytics.view scope, limited to this project. Copy the Project ID (prj_…) from Settings → General. Keep the key in your server's environment, for example VIAKITE_SECRET_KEY.

  5. Read one profile's numbers from your backend

    Your endpoint first checks that the signed-in user owns the profile, then asks Viakite. Views and visitors per day, then link clicks by link:

    src/profile-stats.ts
    1const API = "https://us.api.vk.viabio.me/v1/projects/prj_…/analytics/query";
    2
    3async function query(body: object) {
    4 const res = await fetch(API, {
    5 method: "POST",
    6 headers: { Authorization: `Bearer ${process.env.VIAKITE_SECRET_KEY}`, "Content-Type": "application/json" },
    7 body: JSON.stringify(body),
    8 });
    9 if (!res.ok) throw new Error(`viakite ${res.status}: ${(await res.json()).error?.code}`);
    10 return res.json();
    11}
    12
    13export async function profileStats(profileId: string) {
    14 const views = await query({
    15 measures: ["events", "visitors"],
    16 date_range: { preset: "30d" },
    17 granularity: "day",
    18 filters: [
    19 { dimension: "props.profile_id", operator: "is", values: [profileId] },
    20 { dimension: "event_name", operator: "is", values: ["Profile view"] },
    21 ],
    22 });
    23 const links = await query({
    24 measures: ["events"],
    25 date_range: { preset: "30d" },
    26 breakdown: ["props.link_id"],
    27 filters: [
    28 { dimension: "props.profile_id", operator: "is", values: [profileId] },
    29 { dimension: "event_name", operator: "is", values: ["Link click"] },
    30 ],
    31 limit: 50,
    32 });
    33 return { views: views.data, links: links.data };
    34}

    views.data has one row a day, { "time": "…", "events": 128, "visitors": 97 }; links.data one row a link, { "props.link_id": "lnk_42", "events": 31 }. Any other dimension works the same way: break down by country, source or device_type to show where a creator's visitors come from.

    On a Node.js server you can use the query helper of @viakite/sdk instead of fetch. It refuses to run in a browser, so the key can't leak there:

    src/profile-stats.ts
    1import { query } from "@viakite/sdk";
    2
    3const report = await query(
    4 { key: process.env.VIAKITE_SECRET_KEY!, project: "prj_…" },
    5 {
    6 measures: ["events"],
    7 date_range: { preset: "7d" },
    8 breakdown: ["props.link_id"],
    9 filters: [
    10 { dimension: "props.profile_id", operator: "is", values: [profileId] },
    11 { dimension: "event_name", operator: "is", values: ["Link click"] },
    12 ],
    13 },
    14);
  6. Cache the answers

    Creators reload their stats often, and many creators share one key's rate limit. Keep each answer in your own cache (memory, Redis, your database) per profile and date range for a few minutes, and serve repeats from there. When Viakite answers 429 rate_limited, wait the seconds its Retry-After header says before trying again.

What to watch

  • Rate limit. Each secret key may make 10 requests a second; on a paid plan the Rate limit card in Settings → API keys raises it to 25, 50 or 100 for every secret key of the organization. Every answer carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset. Sending events is not counted. See API keys.
  • Filters match events. A props.profile_id filter keeps only the custom events carrying that property, which is why each profile view is sent as its own event. Every such event counts toward your plan's events (1M a month on Free, 5M on Pro).
  • Visitors are counted per day. Without cookies a visitor id lasts one day, so over 30 days someone who came back on three days counts as three.
  • Public pages stay site-wide. A public page or share token shows the whole project's numbers and can't be fixed to one profile. Per-creator numbers go through your backend only.
  • Your plan's history. A query reaches back only as far as your plan keeps data: 30 days on Free, a year on Pro.
  • Property limits. Up to 20 flat properties an event; keys up to 40 characters of letters, digits, _, . or - to be usable in a query.