---
title: "Telegram Ads Tracking: Macros and Conversion Postbacks"
description: "How to track Telegram Ads campaigns in AdsGram: macros for web links, conversion postbacks via the Conversion Confirmation API, and automatic Goal 1 events for Mini Apps, bots and channels."
outline: [2,4]
---
# Tracking Telegram Ads
For more detailed tracking of Telegram Ads campaign performance and correct attribution of the sources of target actions, it is recommended to use an **analytics system**.

## Macros supported for Telegram Ads web links
For detailed tracking, use macros. AdsGram will automatically replace them with real data in your tracking link.
- `{campaign_id}`
- `{banner_id}`
- `{publisher_id}`
- `{useragent}`
- `{click_id}`
- `{ip}`
- `{campaign}` — campaign name

> [!IMPORTANT]
> This support applies only to web links in Telegram Ads. AdsGram macros are still not supported for links leading to Telegram Mini Apps (TMA), bots, or Telegram channels in Telegram Ads campaigns.

::: warning
For the Conversion Confirmation API to work correctly with web links in Telegram Ads campaigns, the campaign URL must include the `{campaign_id}` macro. If the required macro is missing, conversion tracking will fail.

In Telegram Ads campaigns, AdsGram macros are not supported for links leading to Telegram Mini Apps (TMA), bots, or channels. Therefore, the conversion confirmation API cannot be used to track conversions from such links in Telegram Ads campaigns. For more information, see [Conversion tracking for links within Telegram in Telegram Ads campaigns](#conversion-tracking-for-links-within-telegram-in-telegram-ads-campaigns) below.
:::

> [!IMPORTANT]
> The macro `{publisher_id}` is revealed only as a unique publisher identifier — without specifying its name or other identifying information.

Example of campaign URL:
```
https://your-tracker.com/?campaign={campaign_id}&banner={banner_id}&pub={publisher_id}&clickid={click_id}
```

The dashboard highlights the macros added to the link <img src="../images/icons/added_macros.png" alt="Added macros" width="18" style="display: inline" /> and the ones that are missing <img src="../images/icons/missed_macros.png" alt="Missed macros" width="18" style="display: inline" />.

![Selected macros](./images/selected_macroses.webp =500x)

## Setting up conversion postbacks for web links in Telegram Ads
### Parameters:
- `token` — a unique token associated with your account. It is available in the AdsGram dashboard and can be regenerated if necessary.

  **How to get your token:**
  1. Open the AdsGram dashboard.
  1. Click your profile in the top-right corner.
  1. Find the `token` parameter and click the copy button <img src="../images/icons/copy.png" alt="Copy" width="18" style="display: inline" /> to copy it.

  ![Copy macros](./images/copy_macros.webp =200x)
- `campaignid` — the ID of the AdsGram advertising campaign. It corresponds to the value of the `{campaign_id}` macro passed in the tracking link. AdsGram inserts the macro value when a user clicks the link.
- `goaltype` — a parameter that specifies the type of conversion (funnel stage), helping to segment various user actions. It accepts integer values from 1 to 3.

  ##### goaltype usage:
  1. Define the funnel stages in your product or service.
  1. Map the stages to goaltype values:
      - 1. Registration
      - 2. First deposit/purchase
      - 3. Repeat deposit/purchase
  1. Configure conversion tracking for the relevant stages of the user journey.
  1. Add the goaltype parameter to your API request when sending conversion data.
  1. Use this parameter in your analytics to perform a detailed performance analysis by conversion type.

### How to set up conversion tracking:
1. **Select a Telegram Ads campaign.** Use an existing active campaign or create a new one.
1. **Configure the tracking link.** Make sure it contains the `{campaign_id}` macro.
1. **Get your token.** Copy your unique token from the AdsGram dashboard.
1. **Set up postback delivery.** Configure your server to send an API request to AdsGram whenever a user completes a target action.
1. **Specify the conversion type.** Set the appropriate `goaltype` value if you want to distinguish between funnel stages.
1. **Test the integration.** Follow the steps in the **Integration testing** section below and verify that conversions appear in AdsGram statistics.

#### Example of API request upon conversion:
```
GET
https://api.adsgram.ai/confirm_conversion?token=YOUR_UNIQUE_TOKEN&campaignid=72156&goaltype=2
```
In this example, `goaltype=2` represents a conversion such as a first deposit or purchase.

Replace `YOUR_UNIQUE_TOKEN` with your account token and `72156` with your advertising campaign ID.

**Expected response:** `200 OK` — the conversion has been successfully registered.

### Integration testing
To test conversion tracking, follow these steps:
1. **Create or select a campaign.** Create or select a Telegram Ads campaign and configure the tracking link according to the documentation. Make sure the `{campaign_id}` macro is included in the link.
1. **Wait for clicks.** Wait until users have clicked the tracking link several times.
1. **Send a test postback manually** with the `goaltype=1` parameter. Use a valid `token` and the ID of the test campaign in the `campaignid` parameter.
1. **Check the result.** Verify that the request was processed successfully and that the conversion appears in AdsGram statistics for the selected campaign.

### Troubleshooting
- **The conversion appears in statistics:** the integration is configured correctly and working for the tested scenario.
- **The server returns an error:** check the request URL and the values of the `token`, `campaignid`, and `goaltype` parameters.
- **The request succeeds, but the conversion does not appear:** statistics are updated once per hour. If the conversion is still missing after one hour, contact AdsGram Support or your account manager. Be sure to include the request and response logs in your support request.

## Conversion tracking for links within Telegram in Telegram Ads campaigns
AdsGram macros are not supported for links leading to destinations within Telegram in Telegram Ads campaigns and are not passed through to these advertising links. Therefore, the conversion confirmation API cannot be used to track conversions from links leading to Telegram Mini Apps (TMA), bots, or channels.

For links within Telegram in Telegram Ads campaigns, the following target events are automatically reported as **Goal 1** by default:
- TMA — TMA launch;
- Bots — bot launch;
- Channels — channel subscription.

Conversions are reported automatically, so no additional configuration is required.
