@personaxyz/ad-sdk-programmatic

0.0.4 • Public • Published

Persona Ad SDK Programmatic

Persona Ad SDK Programmatic is a JavaScript-based software development kit that enables web app developers to display digital advertisements on their web apps. This SDK provides seamless integration with vanilla JavaScript.

Integration

The SDK can be integrated in the following way:

  1. Integrating through <script> tags using cdn

1. Integration via script tag

To load the Persona Ad SDK in your app and initialize an ad client, insert the following scripts in the <head> section of your app / page.

<script src="https://cdn.jsdelivr.net/npm/@personaxyz/ad-sdk-programmatic@0.0.4" crossorigin="anonymous"></script>
<script type="text/javascript">
    var personaConfig = {
        apiKey: "XXXX_api_key_staging_XXXX", // An actual API key is generated once you register an app with us.
        environment: "production",
    }
    var sdk = new PersonaAdSDK.PersonaAdSDK(personaConfig);
    var adClient = sdk.getClient()
</script>

Now to render a banner ad, an ad slot needs to be present in the app where the ad will render. For instance, to render a banner ad with 300x250 dimensions , add the following snippet inside the <body> tag of your app.

<div id="my-banner-ad"></div> // The ad will render here
<script>
    adClient.setUserEmail('janedoe@email.com') // If available in your app
    adClient.setWalletAddress("1Lbcfr7sAHT...."); // If available in your app
    adClient.showBannerAd({
        adUnitId: "cf20c750-2fe4-4761-861f-b73b2247fd4d", // An ad unit id is provided by Persona for production environment
        containerId: "my-banner-ad", // HTML element's id where the ad needs to render on the app
        adConfig: {
          dimensions: "300x250",
        },
    })
</script>

Similarly, more banner ads can be rendered using the above snippet with correct adUnitIds and containerId. One such implementation for an ad with 970x90 dimensions is as follows

<div id="my-banner-ad-2"></div> // The ad will render here
<script>
    adClient.setUserEmail('janedoe@email.com') // If available in your app
    adClient.setWalletAddress("1Lbcfr7sAHT...."); // If available in your app
    adClient.showBannerAd({
        adUnitId: "3a094192-4c7b-4761-a50c-bd9b6a67e987", // An ad unit id is provided by Persona for production environment
        containerId: "my-banner-ad-2", // HTML element's id where the ad needs to render on the app
        adConfig: {
          dimensions: "970x90",
        },
    })
</script>

NOTE : Please ensure that the showBannerAd method is called after the HTML element being referred to in the method is rendered on the app.

For the production environment, an app needs to be registered with us which generates different api keys and ad unit ids.

Additional Features

Supported banner Ad Formats

  1. 300x250
  2. 970x90

NOTE: An ad's dimensions can be configured while creating an ad unit

Readme

Keywords

none

Package Sidebar

Install

npm i @personaxyz/ad-sdk-programmatic

Weekly Downloads

4

Version

0.0.4

License

ISC

Unpacked Size

215 kB

Total Files

28

Last publish

Collaborators

  • persona3