Copy the prompt and send it to an AI to generate the analytics code

Analytics

Add one script to your site and view visitors, referrers, pages, devices, and regions in the app console. It uses no cookies and does not store visitor IPs, so no cookie consent banner is needed.

Availability

Analytics is available based on the app owner's plan. The site count and monthly event count are totals across all apps in the account:

PlanSitesMonthly eventsDetail data retention
LiteNot supported——
Plus3100,000180 days
Pro201,000,000730 days
EnterpriseUnlimitedUnlimited1095 days
  • An event is a page view or a custom event, counted per calendar month (Beijing time)
  • Once this month's quota is used up, new visits are no longer recorded, with no effect on your site's visitors; recording resumes automatically on the 1st of next month
  • Detail data is deleted after the retention period; daily summarized overview data is kept long term, so long ranges such as "All time" still show visitor and view trends
  • After a plan drops to Lite, recording stops and historical data becomes read-only; a site's data can be cleared at any time in the console, or deleted along with the site

Integration

Open the app detail page > "Analytics", click "Add site", and copy the embed code into the <head> of every page on your site (or into a shared site-wide template):

<script defer src="https://connect.czl.net/<script-path>" data-id="<site-id>"></script>

The embed code shown in the console contains the final address; copy and use it as is. Route changes in single-page apps (React / Vue / Next.js, etc.) are tracked automatically, with no extra code.

The script and reporting addresses are fixed to the CZL Connect domain, and self-hosted reverse proxies are not supported: behind a proxy, the analytics service sees the proxy server's IP, so every visitor's region is recorded as the proxy's location.

Optional attributes

AttributeDescription
data-idRequired, the site ID
data-auto="false"Turns off automatic page view tracking; call czl.pv() manually instead
data-dnt="true"Skip tracking when the browser has Do Not Track enabled (not checked by default)

Custom events

// Record an event; up to 10 properties, with string / number / boolean values
czl.ev('signup', { plan: 'pro' });

Or add the data-czl-ev attribute to an element to report on click:

<button data-czl-ev="download">Download the client</button>

Events appear in the "Custom events" card on the dashboard.

UTM campaign parameters

When the page URL carries utm_source / utm_medium / utm_campaign, they are recorded automatically and appear in the "Campaigns" card; visits with utm_medium=cpc or ad click parameters such as gclid are classified under the "Paid ads" channel.

Allowed domains

In the site settings you can enter allowed domains (one per line; *.example.com matches all subdomains). Leave empty for no restriction; once set, only pages on these domains are counted, which stops others from pasting your embed code onto other sites and consuming your quota.

Metric definitions

MetricDefinition
VisitorsDeduplicated anonymously per month: the same browser counts as one visitor within a calendar month, and cannot be linked across months
VisitsA new visit starts when the same visitor has been inactive for more than 30 minutes
Page viewsNumber of page views (including route changes in single-page apps)
Bounce rateShare of visits that viewed only one page
Average visit durationThe average time between the first and last event within a visit
Online nowVisitors active in the last 5 minutes
  • Channel (Direct / Organic search / Social / Email / Paid ads / Referral) and referrer domain are determined by the first page of each visit; navigation within your site does not count as a referrer
  • Time ranges and time-of-day distribution use the viewer's browser time zone
  • Bot traffic such as search engine crawlers is excluded automatically
  • Click any row on the dashboard to filter by that value; the filter applies to the whole page

Counter badge

A publicly viewable SVG counter badge that you can paste into a README or web page to show traffic. It takes effect after you turn on "Public counter badge" in the site settings (once on, anyone can see the numbers through the badge URL); click "Counter badge" on the dashboard to generate the URL.

https://connect.czl.net/<badge-path>/<site-id>/<metric>.svg
MetricMeaning
todayDaily visitors (deduplicated visitors today)
monthMonthly visitors (deduplicated visitors this month)
totalTotal visitors (sum of monthly visitors)
viewsTotal page views
pageTotal views of a single page; specify the page with the path parameter

Query parameters:

ParameterDescription
labelLeft-side text; defaults to the metric's display name, and an empty string shows only the number
colorRight-side background color, as hex (such as 4c1) or a name like brightgreen, green, blue, orange, red, grey
labelColorLeft-side background color, same rules as above
styleflat (default) or flat-square
pathpage metric only: the page path. Can be omitted when the badge is placed in a web page, which uses the page it is on

Numbers refresh about every 5 minutes. Images in a GitHub README are loaded through GitHub's proxy, which cannot see the page they are on, so the page metric must specify path. If the site has not enabled the badge, is disabled, or its plan does not support it, the badge shows unavailable.

Markdown example:

![Visitors today](https://connect.czl.net/<badge-path>/<site-id>/today.svg)
![Views of this page](https://connect.czl.net/<badge-path>/<site-id>/page.svg?path=/docs/intro&color=4c1)

Privacy

  • Writes no cookies, localStorage, or any other browser storage
  • Visitor IPs are used only in memory to resolve country / city, and are not stored
  • Visitor IDs are computed with a random salt that rotates monthly; once the salt is discarded at month end, they can no longer be linked to earlier visitors
  • Creating, editing, clearing, and deleting a site are recorded in the app's activity log; clearing and deleting require passkey confirmation