thelastapi
Get started free

Where your visitors come from: sources, countries and devices

Find where your website traffic sources come from across referrers, countries, and devices without cookies or stored IPs.

On this page 8 sections

You find website traffic sources by tracking page referrers, device headers, and IP-derived geolocation with privacy-focused analytics. thelastapi gives you clean web analytics by default: pageviews, referrers, countries, and device types without using cookies or storing visitor IP addresses. You can inspect your traffic directly from the CLI, run HTTP queries against the analytics API, or view trends across all your projects in Mission Control.

Here is how traffic tracking works, how to read the data, and how to inspect sources across your projects.

How traffic sources, countries, and devices are tracked

Every project created with thelastapi includes the analytics resource by default. The analytics tracker captures the core dimensions of every visit while keeping visitor privacy intact:

  • Sources: When a visitor clicks a link to your site, the browser sends a referrer header. thelastapi labels referrers naturally: chatgpt.com becomes ChatGPT, www.google.com becomes Google, and empty referrers become Direct.
  • Countries: Country data is resolved using a local lookup of the IP address (IP geolocation by DB-IP). The IP address itself is never saved or stored.
  • Devices: Device categories are parsed from the browser's user-agent header to separate phone, tablet, and desktop traffic.
  • Visitor identity: A random id stored in the browser's localStorage keeps a visitor counted as one visitor across days and networks. If you add data-no-storage to the snippet tag, localStorage is disabled; the server then uses a daily-salted hash instead, meaning a returning visitor is counted anew each day.

Bots are dropped automatically, and events are accepted only from your project's verified domains and its free vibiz.app address.

Installing the tracking snippet

On thelastapi hosting, your environment already provides NEXT_PUBLIC_VIBIZ_ANALYTICS_KEY and NEXT_PUBLIC_VIBIZ_ANALYTICS_URL. You can add the tracking script into your site's <head>:

HTML
<script defer src="https://thelastapi.dev/v1/script.js" data-key="vz_pk_..."></script>

If your application runs on an external host, you can still track visits. Initialize an analytics-only project, register your external domain, and grab the snippet:

Terminal
vibiz init mysite --resources analytics
vibiz domains add example.com --elsewhere
vibiz analytics snippet

Paste the snippet before </head> on every page. Because events are accepted only from registered domains, make sure every domain your site answers on is added to the project.

If your site handles authenticated users, connect their sessions so their activity across devices joins together into one record:

JavaScript
// Call after sign-in
vibiz('identify', user.id);

// Call at sign-out
vibiz('identify', null);

When you need to track user actions from backend services, see server-side event tracking from your backend for server calls using @vibiz/app.

Reading traffic data from the CLI and API

You can check traffic sources, countries, and devices directly from your terminal. Use the vibiz analytics command with a 24-hour, 7-day, or 30-day window:

Terminal
vibiz analytics --period 7d

To integrate traffic numbers into your own admin dashboards or automated reporting pipelines, query the API directly:

Terminal
curl "https://thelastapi.dev/v1/projects/prj_123/analytics?period=7d" \
  -H "Authorization: Bearer $VIBIZ_API_KEY"

The JSON response returns structured breakdowns for your project:

JSON
{
  "totals": {
    "pageviews": 1400,
    "visitors": 812
  },
  "sources": [
    { "source": "ChatGPT", "visitors": 300 },
    { "source": "Google", "visitors": 210 },
    { "source": "Direct", "visitors": 150 }
  ],
  "countries": [
    { "country": "US", "visitors": 450 },
    { "country": "DE", "visitors": 120 }
  ],
  "devices": [
    { "device": "desktop", "visitors": 520 },
    { "device": "mobile", "visitors": 292 }
  ],
  "top_pages": [
    { "path": "/", "pageviews": 900 },
    { "path": "/pricing", "pageviews": 240 }
  ],
  "events": []
}

If you run multiple apps or client projects, checking each project one by one takes too long. Console ▸ Mission Control displays a single operational board for all your projects.

Agents and scripts can query this overview using vibiz health or by calling GET /v1/mission-control:

Terminal
curl "https://thelastapi.dev/v1/mission-control" \
  -H "Authorization: Bearer $VIBIZ_API_KEY"

In Mission Control, step 4 is dedicated to Traffic. The canvas reports:

  • 7-day visitors and visitor change percentage compared to the 7 days prior.
  • 30-day visitor trends.
  • The top sources driving visitors across all projects.
JSON
{
  "object": "mission_control",
  "insights": {
    "today": { "visitors": 2400, "sales": 47, "revenue_usd_cents": 230300, "fail": 3, "warn": 12 },
    "top_sources_7d": [{ "source": "ChatGPT", "visitors": 507 }]
  },
  "data": [
    {
      "project": { "id": "prj_123", "name": "Shop", "slug": "shop", "url": "https://shop.com" },
      "steps": [
        {
          "id": "traffic",
          "title": "Traffic",
          "status": "ok",
          "value": 812,
          "value_label": "visitors 7d",
          "line": "140 pageviews in 24 h (7-day average 120 a day)."
        }
      ],
      "metrics": {
        "visitors_7d": 812,
        "visitors_prev_7d": 640,
        "visitors_change_pct": 27,
        "top_sources_7d": [
          { "source": "ChatGPT", "visitors": 300 },
          { "source": "Google", "visitors": 210 }
        ]
      }
    }
  ]
}

Mission Control automatically alerts you to traffic anomalies. Its background health check runs about once an hour: if pageviews over the last 24 hours fall more than 60% below your 7-day daily average (once your average is 20 or more visitors a day), the Traffic check changes to an amber warning status.

Connecting search engines to organic traffic

Organic search engines are one of the most common traffic sources. thelastapi automates search engine discovery through built-in Search tooling.

After every production deploy, thelastapi reads /sitemap.xml and sends new or updated pages to IndexNow, distributing them to Bing, Yandex, Naver, and Seznam. For Google, you can connect your Google Search Console account via a service account key without OAuth sign-in flows:

Terminal
vibiz search connect google --key key.json --owner-email ana@example.com

Once connected, you can review your search impressions and search clicks right next to your analytics:

Terminal
vibiz search

This returns indexation states, 28-day impression counts, and top queries. When unexpected source changes occur, you can immediately tell whether a change in search clicks is responsible.

Pairing traffic source data with session replay

Traffic source numbers show where visitors arrive from, but not what they experience when landing on your site. If traffic from mobile devices or a specific referrer bounces immediately, you can inspect their actual browsing path.

When the replay resource is added (vibiz add replay), sessions are recorded by default and masked directly in the browser:

Terminal
vibiz replays --period 7d

If an influx of mobile visitors encounters broken UI, you can pull screenshots of exact failure moments:

Terminal
vibiz replays frames rpl_123 --moments error,rage_click --out frames

Frames let you view the page as rendered on the visitor's device width without storing raw user credentials. To see how recording masking protects user data, read session replay for a small site: masked, cheap and useful. If unexpected crashes affect incoming traffic, see see the JavaScript errors your visitors actually hit.

Traffic monitoring limits and pricing

ItemSpecificationPrice
Analytics eventsUp to 8 KB JSON payload, max 30 scalar properties$0
Replay recordingMasked in browser; password/card inputs omitted$0 recording ($0.023/GB-month storage + 20% margin)
Allowed domainsProject's own domains (vibiz domains add) and .vibiz.appIncluded
Traffic health alertTriggers warning if 24h pageviews drop >60% below 7d averageIncluded

Read the full overview of dashboard metrics and automated health checks in Mission Control and health checks, or review the tracking client reference in Analytics and replay. Create your account at thelastapi.dev/start to try the platform.

Frequently asked questions

Does the analytics script use cookies to track traffic sources?

No, the tracker does not use cookies and never stores visitor IP addresses. It uses a random id in `localStorage` to recognize returning visitors, or a daily-salted hash if the `data-no-storage` attribute is present.

How are countries determined if IP addresses are not stored?

Countries are identified at the moment of request via a local DB-IP database lookup. The source IP is discarded immediately after the country code is determined.

Why are traffic events from my external domain being rejected?

Events are accepted only from domains registered to your project. Add external domains with `vibiz domains add example.com --elsewhere` so the analytics gateway can verify incoming origins.

What triggers a traffic health warning in Mission Control?

Mission Control raises a warning if pageviews over the last 24 hours drop more than 60 percent below the 7-day daily average, provided your daily average is at least 20 pageviews.