TappAds
  • About TappAds
  • TappAds for user acquisition (for advertisers)
    • How TappAds work
    • How much does a user cost?
    • Instructions for integration
      • SDK Integration Instructions
        • Steps for Testing the Integration
      • Server-to-server integration
      • SDK Integration Instructions(Multi-Step Tasks)
      • Server-to-server integration(Multi-Step Tasks)
      • Integration for Mobile Apps promotion
    • FAQ for advertisers
  • TappAds for traffic monetization (for app owners)
    • How TappAds work
    • Why work through TappAds
    • Integration instructions
    • Questly integration guide
    • Feed integration
      • Server-to-server integration guide
      • SDK integration guide
    • [deprecated] Instructions for manual integration
    • FAQ for publishers
Powered by GitBook
On this page
  • Step 1. Connect the SDK
  • Step 2. Initialize the SDK
  • Step 3. Configure the Target Action
  • Example of Full Integration Code
  • Conclusion
  1. TappAds for user acquisition (for advertisers)
  2. Instructions for integration

SDK Integration Instructions(Multi-Step Tasks)

We’re excited to introduce multi-step tasks! Now advertisers can set up progressive rewards, like:

βœ… Open the app β†’ Get a reward 🎯 Reach Level 2 β†’ Get a bigger reward πŸ† Reach Level 10 β†’ Get an even bigger reward

This is a game-changer for advertisers who want to drive deeper user engagement and maximize conversions.

Step 1. Connect the SDK

In the head section of your Telegram Mini App page, you need to add the SDK script. This will allow you to track events, send data on target actions, and receive analytics.

<script src="https://sdk.tappads.io/adv/sdk_v1.js"></script>

Step 2. Initialize the SDK

After connecting the script, you need to initialize the SDK with your API key (adv_apikey). This key has been provided to you to interact with our platform.

TappAdsAdvSdk.init('your_adv_apikey', {
    debug: true, // Leave as true for debugging
})
.then(() => {
    console.log('TappAdsAdvSdk initialized');
})
.catch(err => {
    console.error('Error initializing TappAdsAdvSdk:', err);
});

Important: Make sure to use the correct API key. If the initialization is successful, you’ll see a success message in the console.

Step 3. Configure the Target Action

To track a target action (e.g., opening the TMA or performing an in-app action), use the TappAdsAdvSdk.event method. This will send an event when the user performs the specified target action.

TappAdsAdvSdk.event({
    isOld: false // Set to true if the user has already been in the app before
    eventName: 'event_name' // state the name of your step
})
.then(() => {
    console.log('Event successfully sent');
})
.catch(err => {
    console.error('Error sending event:', err);
});
  • Parameter isOld:

    • false β€” if this is a new user.

    • true β€” if the user has previously been in the app and is performing the action again.

Note: Configuring this parameter is important for identifying unique users and accurately calculating payments for new users.

  • Parameter eventName:

    • You can give the name of the event any lowercase name. Example: init, install, level_1

    • It is desirable to keep the first event as simple as possible. Ideally: start the application

Example of Full Integration Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Your Telegram Mini App</title>
    <!-- Connect the SDK script -->
    <script src="https://sdk.tappads.io/adv/sdk_v1.js"></script>
</head>
<body>
    <script>
        // Check if TappAdsAdvSdk object exists
        if (typeof TappAdsAdvSdk === 'undefined') {
            console.error('TappAdsAdvSdk is not loaded. Please check the SDK connection.');
        } else {
            // Initialize the SDK
            TappAdsAdvSdk.init('your_adv_apikey', { debug: true })
            .then(() => {
                console.log('TappAdsAdvSdk initialized successfully');
                // Send the target event after successful initialization
                trackEvent();
            })
            .catch(err => {
                console.error('Error initializing TappAdsAdvSdk:', err);
            });

            // Function to send the target event
            function trackEvent() {
                TappAdsAdvSdk.event({ isOld: false, eventName:'event_name'})
                .then(() => {
                    console.log('Event sent successfully');
                })
                .catch(err => {
                    console.error('Error sending event:', err);
                });
            }
        }
    </script>
</body>
</html>

Conclusion

  • Check for the presence of TappAdsAdvSdk before initialization.

  • Use the TappAdsAdvSdk.event() function to log the target action.

If you have any questions, please contact our support team.

PreviousServer-to-server integrationNextServer-to-server integration(Multi-Step Tasks)

Last updated 3 months ago