Function createAd

  • Creates an ad placement.

    Parameters

    • id: string

      The id for the placement. For most placement types, this should be the id of a div that the ad will fill.

    • options: NitroAdOptions

      The options object containing settings for the placement.

    Returns
        | NitroAd
        | Promise<NitroAd>
        | Promise<NitroAd[]>
        | null

    Depending on loading state, this may return a promise or an object.

    The id used for a placement must be unique on the page it appears, and should be a stable identifier for the ad placement. Randomized values should not be used for id.

    // basic usage
    window.nitroAds.createAd('banner-1', {
    sizes: [[728, 90]],
    });
    // you can wrap with Promise.resolve to handle case where return may be a promise or not
    Promise.resolve(window.nitroAds.createAd('banner-1', {})).then((ad) => {
    // now save ad object for later use
    });
    // you can also just use await in an async function
    let ad = await window.nitroAds.createAd('banner-1', {});