Skip to content

Telegram Mini Apps Widget Integration Guide

Learn how to integrate ad widgets into your Telegram Mini Apps effectively.

Basic Integration

Add this script to your HTML using Your Widget ID generated after widget creation:

html
<script type="text/javascript" src="https://cdn.tgads.space/assets/js/tg-ads-co-widget.min.js"></script>
<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', () => {
        const adexiumAds = new AdexiumWidget({
            wid: 'YOUR_WIDGET_ID', 
            adFormat: 'push-like', //adFormat values available: push-like/interstitial
            firstAdImpressionIntervalInSeconds: 5, // by default ad will appear in 20 seconds after opening mini apps
            adImpressionIntervalInSeconds: 100, // by default ad period interval is 200 seconds
            debug: true // you can pass this parameter to debug and get TEST ad every time you make request. Do not use on production ENV :)
        });
        adexiumAds.autoMode(); // if you want to show AD in auto mode if not - do not call this method
    });
</script>

If you would like to show ad manually there are some methods and events available to use:

Request Ad Method:

js
adexiumAds.requestAd('interstitial'); // request an Ad interstitial/push-like
adexiumAds.requestRewardedAd('interstitial'); // Rewarded Ad request

Ad found and received:

javascript
const adReceivedListener = (ad) => {
    adexiumAds.displayAd(ad); // display ad using our styles
    //taskId = ad.id 
};

// subscribe
adexiumAds.on('adReceived', adReceivedListener);
 
// unsubscribe
adexiumAds.off('adReceived', adReceivedListener);

Response example ad:

json
[{
    "creativeUrl": "https://cdn.tgads.space/creatives/images/cf5e1ddb279099500910042f4c897ea2.webp",
    "notificationUrl": "https://postback.tgads.live/impression?imp_id=64c286d8-04a2-4f4b-ac80-e455d8cbe020",
    "clickUrl": "https://postback.tgads.live/click?click_id=64c286d8-04a2-4f4b-ac80-e455d8cbe020",
    "buttonText": "Go!",
    "title": "Ready for action, User? Play now!",
    "adFormat": "push-like",
    "description": "Blast Cannon: Aim, fire, win\u2014just for you! "
}]

Ad not found:

javascript
const noAdFoundListener = () => {
    console.log('no ad found');
};

// subscribe
adexiumAds.on('noAdFound', noAdFoundListener);

//unsubscribe
adexiumAds.off('noAdFound', adReceivedListener);

Ad found and redirected:

javascript
adexiumAds.on('adRedirected', () => {
    alert('clicked and redirected');
});

Ad rendered and displayed

javascript
adexiumAds.on('adDisplayed', () => {
    alert('Ad Displayed');
});

Ad closed by user

javascript
adexiumAds.on('adClosed', () => {
    alert('Ad adClosed');
});

Ad playback completed user viewed ad.

javascript
adexiumAds.on('adPlaybackCompleted', () => {
    alert('adPlaybackCompleted');
});

Method .off works for each event, do not forget to pass listener. adexiumAds.off('eventName', listenerFunction);

To check if task is completed send S2S postback to this URL:

http
GET https://bid.tgads.live/task/check/{widgetId}/{taskId}

taskId = id from callback adReceivedListener(ad) {ad.id} Response:

json
{
  "done": false
}

How Ad looks like?

You can use our Example bot to see all formats: @AdexiumExampleBot