Create Banner Ads

Instructions on how to create banner ads by integrating your codes into OpenAD Protocol.

Preparations

Make sure that you complete Create Your Ad Placement before you start the following steps.


Github Codes And Demo

https://github.com/openad-protocol/openad-tg-ad-demo


Easy embedding

Step #1. Load SDK

Load the SDK in the body of html, the code is as follows:

<head>
  <!--Your codes above-->
  <script
      name="OpenADTGJsSDK"
      version="4.0"
      type="text/javascript"
      src="https://protocol.openad.network/tg/sdk.loader.js">
  </script>
</head>

We recommend to add your application version number or release timestamp after JS to obtain the latest JS SDK for your application. E.g.,

https://protocol.openad.network/tg/sdk.loader.js?t=your-app-release-timestamp

https://protocol.openad.network/tg/sdk.loader.js?v=your-app-version

The following global vairables will be loaded with 'https://protocol.openad.network/tg/sdk.loader.js'.

  • openADSdkLoader.hostURL , node api url to serve end user. e.g., https://bf2055756e.api.openad.network .

The script will pick OpenAD node for your end users, and load proper version of OpenAD SDK for you.

Step #2. Add DOM placeholder for Ad banner

zoneld="158", 158 is a demo zoneld, please use your own "zoneId"

publisherld="49", 49 is a demo publisherld, please use your own "publisherld"

feel free to define your own banner style

OpenAD SDK will get ad banner for your end users and has it rendered in the DOM placeholder.

In traditional web applications, you can see OpenAD banner been rendered.

!!! OpenAD only support ONE DOM placeholder in one web page.

Enjoy the OpenAD ecosystem !!!


Step #3. Init OpenAD Resource

In most SPA (single page application) web frameworks, DOM objects are rendered dynamically. Thus, the ad banner shall be init manually, the init js call will render ad banners to predefined DOM placeholder.

Please follow the guideline to add the following js codes.

1. If your web application is a TMA (Telegram Mini App), please use the following codes.

2. If your web application is a web3 app and has a wallet provider, please use the following codes.

When wallet pass into SDK, please initialize the user's wallet in advance to ensure that wallet.provider can get the user's wallet address;

When wallet.type = 'eth', you should use codes as below;

When wallet.type = 'kaia', you should use codes as below;

When wallet.type = 'ton', you should use codes as below;

3. If your web application is a web3 app and wallet was created by backend, please use the following codes.

4. If your web application is a web app, please use the following codes.

init/load OpenAD resource manually


Explicit Call Functions

1. Load SDK

.......

2. Get Ad Info

3. Log User View

When the page loads the ad resources and users can see the ads, please execute the following SDK method.

4. Log User Click

When users click on the ad, please execute the following SDK method:

Last updated