Tracking Telegram Mini Apps (TMA) & WebApps
Telegram-боти · 5 min читання
What are Telegram Mini Apps (TMA)?
Telegram Mini Apps (WebApps) allow you to run full web applications, such as stores, casinos, or games, directly inside Telegram. Unlike standard bots, TMAs require a specific tracking approach to bridge the gap between the Telegram chat and your web application.
Connecting Your TMA to GramPixel
To properly track users moving from your ads → to your bot → into your Mini App, you must pass the tracking data through the Telegram Menu Button.
- Connect your bot to GramPixel (see "Connecting Your First Telegram Bot").
- In Telegram, open
@BotFatherand select your bot. - Navigate to
Bot Settings→Menu Button→Configure menu button. - Enter the URL of your web application. CRITICAL: You must use a GramPixel Tracking Link or append our tracking parameters to your URL. This allows GramPixel to pass the user's
session_idinto your app.
Tracking Internal Events (Purchases, Registrations)
Once the user is inside your TMA, you can track their actions using the GramPixel REST API or our JavaScript Snippet.
- Capture the
tg_user_idfrom the Telegram WebApp object (window.Telegram.WebApp.initDataUnsafe.user.id). - When a user makes a purchase or completes a registration, send a POST request to the GramPixel Custom Events API (
/v1/events/ingest). - Include the
telegram_idand theevent_name(e.g., "Purchase").
GramPixel will automatically match this internal event back to the original Facebook or TikTok ad click that brought the user to your bot.
