Documentation
Installation, events, the server API and privacy.
Nothing matched. Try "script", "events", "revenue" or "privacy".
Installation
One line in <head> on every page. Single-page apps need nothing extra: a route change counts as a pageview on its own.
<head>
<script defer data-site="YOUR_SITE_ID" src="https://analitic.my-it.uz/js/da.js"></script>
</head>
{{-- resources/views/layouts/app.blade.php --}}
<head>
<script defer data-site="YOUR_SITE_ID" src="https://analitic.my-it.uz/js/da.js"></script>
</head>
// app/layout.tsx
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<Script
src="https://analitic.my-it.uz/js/da.js"
data-site="YOUR_SITE_ID"
strategy="afterInteractive"
/>
</body>
</html>
);
}
Site settings → More → HTML code for the HEAD section
<script defer data-site="YOUR_SITE_ID" src="https://analitic.my-it.uz/js/da.js"></script>
// functions.php вашей темы
add_action('wp_head', function () {
echo '<script defer data-site="YOUR_SITE_ID" src="https://analitic.my-it.uz/js/da.js"></script>';
});
Replace YOUR_SITE_ID with the id from your site settings.
Script options
The tracker is configured with attributes on the script tag.
data-site- Site id. Required.
data-persist="1"- Keeps a visitor id in localStorage. Needed for revenue attribution.
data-hash="1"- Counts #fragments as separate pages.
data-outbound="0"- Turns off outbound link tracking.
data-exclude="/admin/*"- Paths to skip. Comma separated.
data-api- Your own collector endpoint.
Custom events
The analitic function is available as soon as the script has loaded. The name is yours to choose; properties are optional.
analitic('signup', { plan: 'pro' });
// Идентификатор посетителя — передайте его на свой сервер,
// чтобы привязать к нему будущую оплату:
analitic.visitorId();
For an event to count as a goal, create a goal with the same name in the site settings.
Telegram
A referrer of "t.me" is the same for a Mini App, the in-app browser, a channel post and a private message. Analitic tells those apart on its own, but which post brought someone is only knowable if the post is marked.
Marking a post
Add a tg parameter to the link with a label of your choosing. Any value, up to 64 characters.
https://example.uz/catalog?tg=post_42
Mini App
Nothing to do: Analitic reads start_param from the Telegram SDK. Open the Mini App with t.me/bot/app?startapp=post_42 and post_42 shows up in the report.
An order placed in a chat
The order arrives in a private message rather than on the site. To tie it back to the channel: the "Message us" button on your site carries the visitor id, Telegram passes it to the bot as the start parameter, and the bot sends the payment event with that same id.
// 1. Кнопка на сайте
document.querySelector('#write-to-us').href =
analitic.telegramLink('myshopbot');
// 2. Бот получает /start <visitor_id> и сообщает об оплате
POST https://analitic.my-it.uz/api/v1/event
Authorization: Bearer da_••••••••
{
"name": "order_paid",
"visitor_id": "<то, что пришло в start>",
"amount": 350000,
"currency": "UZS"
}
Works only with data-persist="1": without a stored id there is nothing to tie together.
What shows up in the report
Telegram- Mini App, in-app browser or tagged link
Telegram post- The tg parameter or start_param value
Server events and revenue
Payments happen on your server, not in the browser, so revenue is sent as its own request carrying the site token.
curl -X POST https://analitic.my-it.uz/api/v1/event \
-H "Authorization: Bearer da_your_token" \
-H "Content-Type: application/json" \
-d '{
"name": "subscription_paid",
"email": "customer@example.com",
"amount": 19.00,
"currency": "USD"
}'
At least one of visitor_id, external_id or email is required, otherwise there is nobody to attach the event to. Get visitor_id in the page with analitic.visitorId().
Request fields
| Field | What it means |
|---|---|
name |
Event name. Required. |
visitor_id / external_id / email |
Who the event belongs to. At least one. |
amount |
The sum, for revenue events. |
currency |
Three-letter code. Defaults to the site currency. |
occurred_at |
When it happened. Defaults to now. |
props |
Your own event properties. |
Privacy
A visitor is identified by a hash built with a salt that rotates every day. Tomorrow the same person gets a different identifier, so no cross-day profile exists. In the default setup the script writes nothing to the browser, collects no name, email or phone of its own, and needs no consent banner. Anything that belongs to a named person reaches us only if you send it through the server API yourself — and that part is yours to answer for.
The exception is data-persist. It keeps an id in the site's localStorage so a payment can be tied back to the first source. Without it, revenue attribution only works within a single visit.
Without data-persist the salt rotates daily, so a payment can only be linked to a visit within the same day. With it, across visits — but that is a write to the visitor's browser, and in the EU it may require their consent.
Country and city come from the DB-IP Lite database (CC BY 4.0). Nothing leaves the server: the database is local.
Checking the install
Open your site in a new tab and come back to the dashboard — numbers appear within seconds.
- Nothing after a minute: check data-site against the id in the site settings — without a match the script quietly sends nothing. Where the tag sits does not matter: it carries defer and works in <head> or <body> alike.
- A load error in the console: either an ad blocker is refusing the script URL, or your own Content-Security-Policy is — the script domain belongs in script-src and the collector address in connect-src.
- Traffic arrives but revenue does not: check the site token, and that the request carries visitor_id, external_id or email.
- Pages you do not want are counted: add them to data-exclude.