Skip to content

Setting Up a Postback to Track Conversions in a Telegram Bot

Introduction to RichAds

To track conversions from your ads in a Telegram bot, you need to set up a postback URL that sends the click_id back to our tracking system when a user interacts with your bot.

Important Note

🚫 & is not allowed in Telegram deep links! Use __ (double underscore) or another separator instead to avoid breaking the URL.

Here’s how to implement it correctly:

Step 1: Set Up the Ad Destination URL

When creating your ad, use the following URL format to pass the click_id to your Telegram bot:

https
https://t.me/yourBotName?start=yourStartParams__clickId=[CLICK_ID]

Replace:

  • yourBotName → Your bot’s username (e.g., myTestBot)
  • yourStartParams → Any additional parameters you want (optional)
  • [CLICK_ID] → Our dynamic click identifier (keep this as-is)
  • __ → Used instead of & (since & breaks Telegram links)

Example:

https
https://t.me/myTestBot?start=promo123__clickId=[CLICK_ID]

Step 2: Retrieve the clickId from Telegram’s Webhook

When a user clicks /start in your bot, Telegram sends a webhook request with the full command, including the clickId.

json
{
  "message": {
    "text": "/start start=promo123__clickId=abc123xyz"
  }
}

How to Extract clickId:

  • Parse the /start command and split by __ to separate parameters.
  • Then extract the clickId value.

Step 3: Send the clickId Back to Our Postback URL

Once you have the clickId, send it to our tracking system via a GET request to:

https
https://us.ahows.co/log?action=conversion&key=CLICK_ID_VALUE

Replace CLICK_ID_VALUE with the actual clickId you extracted.

Example Request:

https
https://us.ahows.co/log?action=conversion&key=abc123xyz

Step 4: Verify the Postback

  • Test by clicking your ad link and checking if the clickId is received correctly.
  • Ensure your bot properly extracts and sends the clickId to our postback URL.

Common Issues & Fixes

Problem: Telegram link doesn’t work when using &.

Solution: Replace & with __ (double underscore) or another safe separator.