# Conversions

A conversion is a click on an ad that was followed by the action the campaign is after. This guide says which actions exist, how a campaign decides which one counts, how the click reaches the advertiser's destination, and how an action gets reported back.

## Actions

An action is something the user did after clicking the ad. The action types are `new_user`, `signup`, `lead`, `purchase`, `deposit`, `subscription`, `test`.

Every action reported for a click is recorded, whatever its type. A click can carry at most one action of each type: a second report of the same type for the same click is a duplicate and is discarded.

## What a campaign counts

Each campaign has a **conversion type**, one of the action types above, defaulting to `new_user`. A click **converts** on its first action of that type; actions of other types are recorded but do not convert the click. Changing the conversion type applies from then on, and earlier conversions stay counted.

Each campaign also has **conversion tracking** on or off. With it on, every impression's destination URL carries a click id, so an action can be attributed to the click. With it off, the URL is served as the advertiser wrote it, so nothing reported against a click id can be attributed, and only the bot below can still attribute an action — it matches the joining user against their own recent clicks rather than against the URL.

## How the click id reaches the destination

A click id is 32 hex characters, unique per impression. When conversion tracking is on, it is placed in the destination URL according to the kind of destination:

- **Website**: as the `click_id` query parameter, e.g. `https://example.com/landing?click_id=<click_id>`.
- **Telegram bot**: appended to the `start` payload as `__imeads_<click_id>`, e.g. `https://t.me/some_bot?start=<original>__imeads_<click_id>`. A bare bot link gets the `start` parameter added. The bot receives it as the payload of the `/start` command.
- **Telegram mini app**: appended to the `startapp` payload the same way, e.g. `https://t.me/some_bot/app?startapp=<original>__imeads_<click_id>`. The app reads it from the WebApp start parameter (`initDataUnsafe.start_param`, also present as `tgWebAppStartParam` in the page URL hash).
- **Telegram channel or group**: nothing is added. There is nowhere to carry it, so those destinations are tracked by the bot instead (below).

The click id is the last thing appended, so the advertiser's own payload stays intact in front of the tag.

## How an action gets reported

There are three ways an action reaches the platform. All three land in the same place: the click's actions, the campaign's conversions, and the advertiser's conversion history in the Mini App, where every report is listed as accepted or discarded with its reason.

### The iMe Ads bot, for channels and groups

Add the bot iMe_ads_bot (https://t.me/iMe_ads_bot) to the channel or group as an admin. From then on, every user who joins is matched against that user's ad clicks of the last 30 seconds; the newest such click without a `new_user` action yet gets one. A chat the bot lost admin rights in stops being tracked and is shown as failed in the Mini App until the bot is made an admin again. A chat the bot was removed from disappears from the list; adding it back as an admin connects it again.

### Postbacks, from the advertiser's server

The advertiser's server stores the click id it received with the user and sends a postback when the user converts. This is the only way to report actions that carry money. See https://ad.api.imem.me/docs/postback.md | docs_postback.

### The pixel, from the advertiser's web page

A script tag on the advertiser's pages picks the click id up from the landing URL, remembers it, and reports the actions the page tells it about. See https://ad.api.imem.me/docs/pixel.md | docs_pixel.

## Outcomes of a report

- **Accepted**: the action is recorded on the click; if it is the campaign's conversion type and the click had not converted yet, the click converts.
- **Discarded, no match**: the click id is not a click of any of this advertiser's campaigns. Typical causes: the id was altered or truncated, it belongs to another advertiser, or the campaign had conversion tracking off and the destination never carried an id.
- **Discarded, duplicate**: an action of that type is already recorded for the click.
