Reputation: 830
We are using telegram bot to post advertisiment messages in channels. Ad message always has a text and inline keyboard button in reply markup. This button is a link to promoted resource. We want to track button clicks but there is a problem. As described here, button must contain exactly one of optional parameters - it means, that there will be no callback query if we use url for button. So, the qustion is - is there any cheating way to track clicks and keep button being link?
Current metod is adding layer on our server. Button is moving to our page on server, that redirects to final url. But it is very bad - often link is other telegram channel link and user's browser is opened, when there' is no need.
Upvotes: 5
Views: 3220
Reputation: 1762
You need any shorten URL service like botanio for example.
Shorten url
Send GET request to
https://api.botan.io/s/?token={token}&url={original_url}&user_ids={user_id}
You get shortened url in a plain-text response (in case the response
code was 200). Codes other than 200 mean that an error occurred.Also, in case of group chats you can add several user_ids:
&user_ids={user_id_1},{user_id_2},{user_id_3}, but currently this data
will not be used (because we don't know which particular user clicked
link).
Start chat with Botan in Telegram for getting token wich required in GET request and follow bot's recomendations. It can be helpful not only for URL track but for any click also.
As the alternative you also may use Google URL Shortener, Bitly or many others.
Upvotes: 2