⌘ K
    Web
    🌵 Web
    Mobile
    🌵 iOS
    🌵 Android
    🌵 React Native
    🌵 Flutter
    Copyright © 2025 AiACTIV

    TABLE OF CONTENTS

    AiactivUniversalSDK

    Ads and Analytics Framework

    Installation

    To install AiactivUniversalSDK, you need to add the following script tag to your HTML file:

    <script>
    window.AiactivSDK||(window.AiactivSDK={}),AiactivSDK.load=function(a){var b=document.createElement("script");b.async=!0,b.type="text/javascript",b.src="https://sdk-cdn.aiactiv.io/aiactiv-sdk.min.js",b.addEventListener?b.addEventListener("load",function(b){"function"==typeof a&&a(b)},!1):b.onreadystatechange=function(){("complete"==this.readyState||"loaded"==this.readyState)&&a(window.event)};let c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)},AiactivSDK.load(function(){AiactivSDK.initialize({containerId:"{ContainerID}", type: {SDK_TYPES}}),AiactivSDK.callMethodsFromContainer()});
    </script>

    This will load AiactivUniversalSDK from our CDN and make it available as a global variable named AiactivSDK.

    • {SDK_TYPE} is adnetwork or dmp.
      • Exp: ['adnetwork', 'dmp']
    • {ContainerID} is containerID from AdNetwork portal site: https://adnetwork-portal.aiactiv.io/#/container/{ContainerID}
      • Exp: 4ceed9c8-c28f-4a7a-8646-9b071f4c29c7@web

    Usage

    AdNetwork

    Banner Ad

    • Create an ads placement on your site:
    <div id="display_ads"></div>
    • Then call for display ads
    window.AiactivSDK.requestAds([
    {
    inventoryId: 1, // your inventory ID from portal,
    placementId: 'display_ads',
    },
    ]);
    • Or this way:
    <div data-aiactiv-sdk-placement="1">
    <script type="text/javascript">
    window.addEventListener('load', function () {
    AiactivSDK.requestAd(1);
    });
    </script>
    </div>
    • For video indexing:
    window.AiactivSDK.requestAds([
    {
    inventoryId: 1, // your inventory ID from portal,
    placementId: 'display_ads',
    timecode: 100,
    },
    ]);
    • In sdkResponse the SDK will response from ad service with friendly format
    const response = await window.AiactivSDK.requestAds([
    {
    inventoryId: 1, // your inventory ID from portal,
    placementId: 'display_ads',
    },
    ]);

    Example:

    {
    "id": "6dcc61bf-5ca4-4ae3-89b7-7bc06c7f207d",
    "cur": "USD",
    "seatbid": [
    {
    "bid": [
    {
    "id": "1_1505_1457",
    "impid": "6980befa-074f-4d3a-bd0c-8c74d0fe757f",
    "price": 1,
    "adm": "<div id='aic_586348793'><script src='https://adnetwork-adserver.aiactiv.io/serve-bid/w_Tuinaw8yLG9swbZ0wv7ZFNhBdrqwB0M8a8NtwKJ6OZxfp95y7udfKCSnLbPkuoedZnin7EcD9LtgDe7khofWxNHjLtnpfz35Ie5yaovkZ0o98SWkakpI2wUiRkMNUewt504P1WC_eZen5J5uxCQQEJUiKE4FxBJ1gP4ctyRE4eUUrzvhx0JGA8YFg4eSpmcYn_ndScTa7A3TqGjqJKrQZOND4YNMMfNUHcSoR3fCafgOoDgsfQ31axsoCe1AxRPgZVDRApG7xlx-3esPmBnfkh03RIWMMRTVUs8sHEklhjtE0Fh3YdJeEsgJ4sSToOlNjB91Ow_J18j5cd7azM0y9bf8TXImN2sExxKaEg9fEJatfcEcm3cmmdEIvt_uJg_w1wzryAW8J4lIBrF1KA-BYhoJR9UBa2mAV9cT8D1o2VTlrXIjDj_LvdrhNq2DZGdrQRC_8qlWUA-zLfDG8CjsXOKwboV---_2LRhMy7QnZnv7LQAryFKjSqW1NnrYU8ESYNHimrqjYKykBm95Wiug==/serve-bid.js?rp={{AUCTION_PRICE}}&requestId={{REQUEST_ID}}&r=586348793&uid=s%3A01HR8GYM00SFVH5YNCDNQ180YW.cvBTxIytIXCZmSToyNsddHplifaD06qbB%2FZGsn%2FIMT4' charset='utf-8'></script></div>",
    "adomain": [
    "aiactiv.io"
    ],
    "crid": "1339",
    "w": 800,
    "h": 500,
    "ext": {
    "aicadn": {
    "waterfall": {
    "got_first_party": true,
    "order": "1339",
    "size": 1
    }
    },
    "file_type": "standard",
    "nvade": "https://adnetwork-adserver.aiactiv.io/view-ad/w_Tuinaw8yLG9swbZ0wv7ZFNhBdrqwB0M8a8NtwKJ6OZxfp95y7udfKCSnLbPkuoedZnin7EcD9LtgDe7khofWxNHjLtnpfz35Ie5yaovkZ0o98SWkakpI2wUiRkMNUewt504P1WC_eZen5J5uxCQQEJUiKE4FxBJ1gP4ctyRE4eUUrzvhx0JGA8YFg4eSpmcYn_ndScTa7A3TqGjqJKrQZOND4YNMMfNUHcSoR3fCafgOoDgsfQ31axsoCe1AxRPgZVDRApG7xlx-3esPmBnfkh03RIWMMRTVUs8sHEklhjtE0Fh3YdJeEsgJ4sSToOlNjB91Ow_J18j5cd7azM0y9bf8TXImN2sExxKaEg9fEJatfcEcm3cmmdEIvt_uJg_w1wzryAW8J4lIBrF1KA-BYhoJR9UBa2mAV9cT8D1o2VTlrXIjDj_LvdrhNq2DZGdrQRC_8qlWUA-zLfDG8CjsXOKwboV---_2LRhMy7QnZnv7LQAryFKjSqW1NnrYU8ESYNHimrqjYKykBm95Wiug==/2?requestId={{REQUEST_ID}}&gdpr_consent=${GDPR_CONSENT_234}&uid=s%3A01HR8GYM00SFVH5YNCDNQ180YW.cvBTxIytIXCZmSToyNsddHplifaD06qbB%2FZGsn%2FIMT4",
    "pb": true,
    "play_type": "standard",
    "prebid": {
    "type": "banner"
    },
    "tp": false,
    "vade": "https://adnetwork-adserver.aiactiv.io/view-ad/w_Tuinaw8yLG9swbZ0wv7ZFNhBdrqwB0M8a8NtwKJ6OZxfp95y7udfKCSnLbPkuoedZnin7EcD9LtgDe7khofWxNHjLtnpfz35Ie5yaovkZ0o98SWkakpI2wUiRkMNUewt504P1WC_eZen5J5uxCQQEJUiKE4FxBJ1gP4ctyRE4eUUrzvhx0JGA8YFg4eSpmcYn_ndScTa7A3TqGjqJKrQZOND4YNMMfNUHcSoR3fCafgOoDgsfQ31axsoCe1AxRPgZVDRApG7xlx-3esPmBnfkh03RIWMMRTVUs8sHEklhjtE0Fh3YdJeEsgJ4sSToOlNjB91Ow_J18j5cd7azM0y9bf8TXImN2sExxKaEg9fEJatfcEcm3cmmdEIvt_uJg_w1wzryAW8J4lIBrF1KA-BYhoJR9UBa2mAV9cT8D1o2VTlrXIjDj_LvdrhNq2DZGdrQRC_8qlWUA-zLfDG8CjsXOKwboV---_2LRhMy7QnZnv7LQAryFKjSqW1NnrYU8ESYNHimrqjYKykBm95Wiug==/1?requestId={{REQUEST_ID}}&gdpr_consent=${GDPR_CONSENT_234}&uid=s%3A01HR8GYM00SFVH5YNCDNQ180YW.cvBTxIytIXCZmSToyNsddHplifaD06qbB%2FZGsn%2FIMT4",
    "vuade": "https://adnetwork-adserver.aiactiv.io/view-ad/w_Tuinaw8yLG9swbZ0wv7ZFNhBdrqwB0M8a8NtwKJ6OZxfp95y7udfKCSnLbPkuoedZnin7EcD9LtgDe7khofWxNHjLtnpfz35Ie5yaovkZ0o98SWkakpI2wUiRkMNUewt504P1WC_eZen5J5uxCQQEJUiKE4FxBJ1gP4ctyRE4eUUrzvhx0JGA8YFg4eSpmcYn_ndScTa7A3TqGjqJKrQZOND4YNMMfNUHcSoR3fCafgOoDgsfQ31axsoCe1AxRPgZVDRApG7xlx-3esPmBnfkh03RIWMMRTVUs8sHEklhjtE0Fh3YdJeEsgJ4sSToOlNjB91Ow_J18j5cd7azM0y9bf8TXImN2sExxKaEg9fEJatfcEcm3cmmdEIvt_uJg_w1wzryAW8J4lIBrF1KA-BYhoJR9UBa2mAV9cT8D1o2VTlrXIjDj_LvdrhNq2DZGdrQRC_8qlWUA-zLfDG8CjsXOKwboV---_2LRhMy7QnZnv7LQAryFKjSqW1NnrYU8ESYNHimrqjYKykBm95Wiug==/3?requestId={{REQUEST_ID}}&gdpr_consent=${GDPR_CONSENT_234}&uid=s%3A01HR8GYM00SFVH5YNCDNQ180YW.cvBTxIytIXCZmSToyNsddHplifaD06qbB%2FZGsn%2FIMT4"
    }
    }
    ],
    "seat": "aicadn"
    }
    ]
    }

    Video Ad

    • Option 1
    <div data-aiactiv-sdk-placement="377">
    <script type="text/javascript">
    window.addEventListener('load', function () {
    AiactivSDK.requestAd(377 ,{
    // Only when using AiActiv's player
    video: {
    player: true // true/false,
    preventPauseWhenClick: false, // true/false;
    loop: false // true/false;
    controls: false // true/false;
    },
    debug: false // true/false,
    });
    });
    </script>
    </div>
    • Option 2
    window.AiactivSDK.requestAds([
    {
    inventoryId: 377,
    placementId: '//your placement ID in DOM',
    options: {
    // Only when using AiActiv's player
    video: {
    player: true, // true/false,
    preventPauseWhenClick: true, // true/false;
    loop: false, // true/false;
    controls: false, // true/false;
    },
    debug: false, // true/false,
    },
    },
    ]);
    • Option 3: In-stream video ad
    window.AiactivSDK.requestAds([
    {
    inventoryId: '// your inventory ID number', // eg: 123
    placementId: '//your video youtube iframe ID in DOM', // eg: "youtube-vid-id"
    options: {
    // Only when using AiActiv's player
    video: {
    videoContentId: '//your video youtube iframe ID in DOM', // REQUIRED!!, string - it must be id of iframe include youtube video, eg: "youtube-vid-id"
    player: true, // REQUIRED!! - true
    preventPauseWhenClick: true, // true/false;
    loop: false, // true/false;
    controls: false, // true/false;
    },
    debug: false, // true/false,
    },
    },
    ]);

    Example iframe youtube

    <iframe
    id={VIDEO_ID} // This one should be pass to videoContentId and inventoryId params in above config
    width="560"
    height="315"
    src="https://www.youtube.com/embed/${VIDEO_CODE}"
    title="YouTube video player"
    frameBorder="0"
    allowFullScreen
    ></iframe>

    Native Ad

    1. Show Native ad by programmatically

    Usage

    const sdkResponse = await window.AiactivSDK.requestAds([
    {
    inventoryId: 1, // your inventory ID from portal,
    },
    ]);

    In sdkResponse the SDK will response native ad response from ad service with friendly format
    Example:

    [
    {
    "inventoryId": "ID of inventory",
    "placementId": "Placement to display ad (optional)",
    "native": {
    "title": "",
    "icon": {
    "url": "",
    "width": 0,
    "height": 0
    },
    "video": {
    "vast": "//VAST CONTENT"
    },
    "description": "",
    "callToAction": "",
    "previewImage": {
    "url": "",
    "width": 0,
    "height": 0
    },
    "link": {
    "landingURL": "",
    "clickTrackers": [
    ""
    ],
    "fallbackLandingURL": ""
    },
    "events": [
    {
    "event": 0,
    "method": 0,
    "value": ""
    }
    ]
    },
    "type": "native",
    "vade": "https://adnetwork-adserver.aiactiv.io/view-ad/EVF40guEu9PsY4I_n63Y6hkXiQH1CP_c0_n1Yrg9zRcsNvukU9FD65KCAZza7eCem77n-y9253VQ_Apu8ubiCrebW-udlU3_oGmH9R2kpEvWBNNGiaX_DgWe5jbAicBjjVFRJooSsyaU0xgCsxcSPbBDxGNN3vghDLdTCQFZ0R1OVZjJ3vKAbAWnWWS_1FatBe7kkV_oLcskWgA4om9ZGU1FFwhzRqwpEOHBNazW76oJg3usudawiKQzJSoyeDjhphcAJvnl0q9Vw9y79ZBjQopMZaSY_iB26yZgM2IktCs9iWPhxR-uXOwBodDw98U1Rf8fL3SydxqeHCXtqwdFu8VuPU9inbEhD9_Ppy4DB4b39d1VZx-2_cB1sGBe1EDq6gz5uxIJAD9hYQwiXOaP9lunp9tcs4EAlXV4QItPOesqHkf2XgmkI7WpjMZuKUSYWer4vBxz7zYJlO8gL-l_KVkmYSEccf-ayQv3UZjLhaEQUknRVB-lgl41HPDC7KaoAIE3hgm27sdNPZllny6euw==/1?requestId=82316461-e92a-4638-a9d7-6c60397e5b7a&gdpr_consent=${GDPR_CONSENT_234}&uid=s%3A01HSF4XD009XH8TKGJWTFRQJ5H.c8VAVbJEz0KmWU3eiiYGBM1ZsSTV4uLwlJXaaifEzgs",
    "vuade": "https://adnetwork-adserver.aiactiv.io/view-ad/EVF40guEu9PsY4I_n63Y6hkXiQH1CP_c0_n1Yrg9zRcsNvukU9FD65KCAZza7eCem77n-y9253VQ_Apu8ubiCrebW-udlU3_oGmH9R2kpEvWBNNGiaX_DgWe5jbAicBjjVFRJooSsyaU0xgCsxcSPbBDxGNN3vghDLdTCQFZ0R1OVZjJ3vKAbAWnWWS_1FatBe7kkV_oLcskWgA4om9ZGU1FFwhzRqwpEOHBNazW76oJg3usudawiKQzJSoyeDjhphcAJvnl0q9Vw9y79ZBjQopMZaSY_iB26yZgM2IktCs9iWPhxR-uXOwBodDw98U1Rf8fL3SydxqeHCXtqwdFu8VuPU9inbEhD9_Ppy4DB4b39d1VZx-2_cB1sGBe1EDq6gz5uxIJAD9hYQwiXOaP9lunp9tcs4EAlXV4QItPOesqHkf2XgmkI7WpjMZuKUSYWer4vBxz7zYJlO8gL-l_KVkmYSEccf-ayQv3UZjLhaEQUknRVB-lgl41HPDC7KaoAIE3hgm27sdNPZllny6euw==/3?requestId={{REQUEST_ID}}&gdpr_consent=${GDPR_CONSENT_234}&uid=s%3A01HSF4XD009XH8TKGJWTFRQJ5H.c8VAVbJEz0KmWU3eiiYGBM1ZsSTV4uLwlJXaaifEzgs",
    "nvade": "https://adnetwork-adserver.aiactiv.io/view-ad/EVF40guEu9PsY4I_n63Y6hkXiQH1CP_c0_n1Yrg9zRcsNvukU9FD65KCAZza7eCem77n-y9253VQ_Apu8ubiCrebW-udlU3_oGmH9R2kpEvWBNNGiaX_DgWe5jbAicBjjVFRJooSsyaU0xgCsxcSPbBDxGNN3vghDLdTCQFZ0R1OVZjJ3vKAbAWnWWS_1FatBe7kkV_oLcskWgA4om9ZGU1FFwhzRqwpEOHBNazW76oJg3usudawiKQzJSoyeDjhphcAJvnl0q9Vw9y79ZBjQopMZaSY_iB26yZgM2IktCs9iWPhxR-uXOwBodDw98U1Rf8fL3SydxqeHCXtqwdFu8VuPU9inbEhD9_Ppy4DB4b39d1VZx-2_cB1sGBe1EDq6gz5uxIJAD9hYQwiXOaP9lunp9tcs4EAlXV4QItPOesqHkf2XgmkI7WpjMZuKUSYWer4vBxz7zYJlO8gL-l_KVkmYSEccf-ayQv3UZjLhaEQUknRVB-lgl41HPDC7KaoAIE3hgm27sdNPZllny6euw==/2?requestId={{REQUEST_ID}}&gdpr_consent=${GDPR_CONSENT_234}&uid=s%3A01HSF4XD009XH8TKGJWTFRQJ5H.c8VAVbJEz0KmWU3eiiYGBM1ZsSTV4uLwlJXaaifEzgs"
    }
    ]

    Friendly Native Object Documentation

    // Title of ads
    // -> position 2 in sample layout
    Title string
    // main description of ads
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = desc
    // normally contain main information of product or ads
    // -> position 3 in sample layout
    Description string
    // addition description of ads
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = desc2
    SubDescription string
    // Sponsored text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = sponsored
    // e.g: "Sponsored by Vinamilk"
    Sponsored string
    // Rating text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = rating
    // e.g: "3.4 stars out of 5"
    Rating string
    // Like text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = like
    // e.g: "1.409.000 Liked"
    // position 5 in sample layout
    Like string
    // Downloads text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = downloads
    // e.g: "1.409.000 Downloaded"
    Downloads string
    // Price text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = price
    // e.g: "$10"
    Price string
    // Sale Price text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = saleprice
    // e.g: "$7" ( mostly use combine with price e.g "(-$10-) $7"
    SalePrice string
    // Phone text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = phone
    // e.g: "0123456789"
    Phone string
    // Address text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = address
    // e.g: "01 Loc 145 Street, Somewhere"
    Address string
    // Display URL - the url used to display in native ads, depend on usage
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = displayurl
    // e.g: "https://vinamilk.com/product/abc"
    DisplayURL string
    // Call to Action text
    // - Get from nativeAd.assets[*].data.value if nativeAd.assets[*].data.type = ctatext
    // e.g: "Buy Now"
    // position 6 in sample layout
    CallToAction string
    // Icon - display icon of product or brand logo
    // - Get from nativeAd.assets[*].img if nativeAd.assets[*].img.type = 1
    // An object contain url and size information of icon
    // Detail about Image object bellow
    Icon ImageObject
    // Preview image of product or ads
    // - Get from nativeAd.assets[*].img if nativeAd.assets[*].img.type = 3
    // An object contain url and size information of main image
    // Detail about Image object bellow
    PreviewImage ImageObject
    // Video of product or ads
    // - Get from nativeAd.assets[*].video
    // An object contain vasttag and landing url plus addition information
    // Detail about Image object bellow
    Video VideoObject
    // Link whenever user clicked on ads
    // - get from nativeAd.link
    // Detail bellow
    Link LinkObject
    // Events when serving ads
    // - get from nativeAd.eventtrackers
    // Detail bellow
    Events []EventObject
    Image Object
    // URL to display image
    // e.g: "https://abc.com/image.png"
    URL string
    // width of image
    Width int
    // height of image
    Height int
    Video Object
    // XML VastTag to display video
    // - Get from nativeAd.assets[*].video
    Vast string
    Link Object
    // Landing url of the clickable link
    // When user is clicked the action should take user to the location of this link.
    // e.g: "https://vinamilk.com/product/abc" -> open webpage
    // e.g: "appstore://app1.com" -> open appstore
    LandingURL string
    // A list of click trackers link
    // This must be fired when click to ads or URL
    ClickTrackers []string
    // In case of LandingURL is not supported on device, this URL should be called instead
    FallbackLandingURL string
    Event Object
    // Type of event
    // - Get from nativeAd.eventtrackers[*].event
    // List of event will be present below
    Event int
    // case impression = 1
    // case viewableMRC50 = 2 (Visible impression using MRC definition at 50% in view for 1 second)
    // case viewableMRC100 = 3 (100% in view for 1 second (ie GroupM standard))
    // case viewableVideo50 = 4 (Visible impression for video using MRC definition at 50% in view for 2 seconds)
    // Calling method (JS tag or pixel url)
    // - Get from nativeAd.eventtrackers[*].method
    // List of method will be present below
    Method int
    // case image = 1 (Image-pixel tracking - URL provided will be inserted as a 1x1 pixel at the time of the event)
    // case javascript = 2 (Javascript-based tracking - URL provided will be inserted as a js tag at the time of the event)
    // Can be URL of method is pixel url or Javascript tag
    // - Get from nativeAd.eventtrackers[*].url
    Value string
    Example apply events for native ad
    export const setInnerHtml = (elm, html) => {
    elm.innerHTML = html;
    var w1 = [];
    Array.from(elm.querySelectorAll('script')).forEach((os) => {
    w1.push(os);
    });
    var f1 = 0;
    var waiting = -1;
    var sit = setInterval(function () {
    if (f1 >= w1.length) {
    clearInterval(sit);
    return;
    }
    if (f1 == waiting) {
    return;
    }
    var os = w1[f1];
    var needWait = os.attributes.src !== undefined && os.attributes.src !== '';
    const ns = document.createElement('script');
    Array.from(os.attributes).forEach((attr) =>
    ns.setAttribute(attr.name, attr.value),
    );
    ns.appendChild(document.createTextNode(os.innerHTML));
    if (needWait) {
    waiting = f1;
    ns.onload = () => {
    f1++;
    };
    ns.onerror = () => {
    console.error(
    '[AIACTIV SDK] unable to load script: ',
    os.attributes.src,
    );
    f1++;
    };
    } else {
    f1++;
    }
    os.parentNode.replaceChild(ns, os);
    }, 100);
    };
    events.forEach((eventTracker) => {
    // Event impression
    if (eventTracker.event === 1) {
    // For image
    if (eventTracker.method === 1) {
    // Embed Pixel
    const pixelTag = document.createElement('img');
    pixelTag.src = eventTracker?.value;
    pixelTag.width = 1;
    pixelTag.height = 1;
    nativeWrapElement.appendChild(pixelTag);
    }
    // For javascript
    if (eventTracker?.method === 2) {
    // Embed JS Tag
    // Create js tag <script src="eventTracker.value"/>
    const embedScriptWrapElement = document.createElement('div');
    nativeWrapElement.appendChild(embedScriptWrapElement);
    const embedJs = `<script src="${eventTracker.value}" type="text/javascript" />`;
    setInnerHtml(embedScriptWrapElement, embedJs);
    }
    }
    });

    Get Time Code Video Indexing

    Usage

    const sdkResponse = await window.AiactivSDK.getVideoIndexingDataByContentId(
    'YOUR_CONTENT_ID',
    );

    In sdkResponse the SDK will response from ad service with friendly format
    Example:

    {
    "content_id": 48,
    "content_uuid": "d3a73cca-b5db-4d31-9033-5ee49e345458",
    "content_name": "Hoa Vương: Tập 20. Sự cố đạo nhái",
    "timecodes": [
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 7,
    "end": 12
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 46,
    "end": 48
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 50,
    "end": 52
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 52,
    "end": 53
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 125,
    "end": 127
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 141,
    "end": 146
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 163,
    "end": 170
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 170,
    "end": 173
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 173,
    "end": 177
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 177,
    "end": 187
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 187,
    "end": 192
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 216,
    "end": 225
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 225,
    "end": 234
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 234,
    "end": 242
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 244,
    "end": 250
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 250,
    "end": 254
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 254,
    "end": 256
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 271,
    "end": 275
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 281,
    "end": 289
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 289,
    "end": 294
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 294,
    "end": 301
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 300,
    "end": 360
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 313,
    "end": 316
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 317,
    "end": 321
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 320,
    "end": 340
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 346,
    "end": 355
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 488,
    "end": 499
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 501,
    "end": 509
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 525,
    "end": 528
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 528,
    "end": 532
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 532,
    "end": 536
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 543,
    "end": 547
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 562,
    "end": 567
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 567,
    "end": 572
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 570,
    "end": 630
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 572,
    "end": 578
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 578,
    "end": 581
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 581,
    "end": 588
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 593,
    "end": 597
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 600,
    "end": 660
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 604,
    "end": 608
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 609,
    "end": 614
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 614,
    "end": 620
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 620,
    "end": 623
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 623,
    "end": 628
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 628,
    "end": 633
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 633,
    "end": 636
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 636,
    "end": 640
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 640,
    "end": 643
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 643,
    "end": 647
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 650,
    "end": 652
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 669,
    "end": 671
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 671,
    "end": 676
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 787,
    "end": 794
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 900,
    "end": 960
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 930,
    "end": 990
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 967,
    "end": 971
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 978,
    "end": 985
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1007,
    "end": 1015
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 1200,
    "end": 1260
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 1230,
    "end": 1290
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1274,
    "end": 1280
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1358,
    "end": 1362
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1377,
    "end": 1388
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1437,
    "end": 1448
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 1500,
    "end": 1560
    },
    {
    "keywords": [
    "Romantic"
    ],
    "start": 1520,
    "end": 1540
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1851,
    "end": 1856
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1893,
    "end": 1897
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1917,
    "end": 1922
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1922,
    "end": 1928
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1928,
    "end": 1931
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1931,
    "end": 1933
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1933,
    "end": 1940
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1958,
    "end": 1964
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1967,
    "end": 1969
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 1987,
    "end": 1990
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2186,
    "end": 2194
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2194,
    "end": 2200
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2200,
    "end": 2207
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2207,
    "end": 2208
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2208,
    "end": 2210
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2212,
    "end": 2215
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2221,
    "end": 2222
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2222,
    "end": 2224
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2224,
    "end": 2229
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2229,
    "end": 2232
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2232,
    "end": 2236
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2240,
    "end": 2246
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2246,
    "end": 2250
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2254,
    "end": 2259
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2259,
    "end": 2264
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2264,
    "end": 2270
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2270,
    "end": 2274
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2275,
    "end": 2278
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2278,
    "end": 2284
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2285,
    "end": 2288
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2293,
    "end": 2299
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2301,
    "end": 2304
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2304,
    "end": 2307
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2324,
    "end": 2326
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2326,
    "end": 2332
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2336,
    "end": 2349
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2352,
    "end": 2357
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2368,
    "end": 2371
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2388,
    "end": 2391
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2395,
    "end": 2397
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2397,
    "end": 2400
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2400,
    "end": 2403
    },
    {
    "keywords": [
    "Food and Beverage"
    ],
    "start": 2558,
    "end": 2560
    }
    ]
    }
    Tracking viewable
    • Example:
    const minimumVisibleDuration = 1000;
    const observerOptions = {
    root: null,
    rootMargin: '0px',
    threshold: 0.5,
    };
    function viewAble(iframe, vade) {
    let visibleSince = 0;
    let refreshIntervalID = null;
    const observer = new IntersectionObserver((changes) => {
    for (const change of changes) {
    const entry = change;
    if (entry.isIntersecting) {
    if (entry.intersectionRatio >= 0.5) {
    visibleSince = entry.time;
    refreshIntervalID = window.setInterval(handleRefreshInterval, 1000);
    }
    } else {
    if (refreshIntervalID) {
    clearInterval(refreshIntervalID);
    }
    visibleSince = 0;
    }
    }
    }, observerOptions);
    observer.observe(iframe);
    function handleRefreshInterval() {
    const currentTime = performance.now();
    const diff = currentTime - visibleSince;
    if (diff >= minimumVisibleDuration) {
    clearInterval(refreshIntervalID);
    visibleSince = 0;
    observer.unobserve(iframe);
    if (vade?.length) {
    fetch(vade).then(() => iframe.setAttribute('data-viewable', true));
    }
    }
    }
    }
    var getIncrementalInteger = (function () {
    var count = 0;
    return function () {
    count++;
    return count;
    };
    })();
    function getUniqueIdentifierStr() {
    return getIncrementalInteger() + Math.random().toString(16).substr(2);
    }
    function createInvisibleIframe(impId) {
    const f = document.createElement('iframe');
    f.id = impId || getUniqueIdentifierStr();
    f.border = '0px';
    f.hspace = '0';
    f.vspace = '0';
    f.marginWidth = '0';
    f.marginHeight = '0';
    f.style.border = '0';
    f.scrolling = 'no';
    f.frameBorder = '0';
    f.src = 'about:blank';
    f.style.display = 'inline';
    f.width = '1px';
    f.height = '1px';
    return f;
    }
    const iframe = createInvisibleIframe();
    const nativeWrapElement = document.getElementById('your-native-ad-id');
    if (nativeWrapElement) {
    nativeWrapElement.appendChild(iframe);
    if (!!window.IntersectionObserver) {
    const vade = 'replace_vade_get_from_sdk_response';
    const vuade = 'replace_vuade_get_from_response';
    const nvade = 'replace_nvade_get_from_response';
    viewAble(iframe, vade);
    } else {
    if (vuade) {
    fetch(vuade);
    }
    }
    window.addEventListener('beforeunload', async (evt) => {
    const isViewable = iframe.getAttribute('data-viewable');
    if (isViewable !== 'true') {
    await fetch(nvade);
    }
    });
    }
    1. Using native ad template
      we have 3 template to select
    • template-1
    • template-2
    • template-3

    Refer this link to see template design.

    Usage

    await sdk.requestAds([
    {
    inventoryId: 1, // your inventory ID from portal,
    placementId: 'placement_id_to_show_ad',
    options: {
    native: {
    template_id: 'template-1',
    },
    },
    },
    ]);
    1. Using native ad with auto-fill option
      For this option the SDK will render native ad content to ad placement

    Usage

    const adUnits = [
    {
    inventoryId: 1, // your inventory ID from portal,
    placementId: 'placement to show ad',
    options: {
    native: {
    placements: {
    title: 'placement of title',
    description: 'placement of description',
    subDescription: 'placement of sub description',
    sponsored: 'placement of sponsored',
    rating: 'placement of rating',
    like: 'placement of like',
    downloads: 'placement of downloads',
    price: 'placement of price',
    salePrice: 'placement of sale price',
    phone: 'placement of phone',
    address: 'placement of address',
    displayURL: 'placement of display url',
    callToAction: 'placement of call to action',
    icon: 'placement of icon',
    previewImage: 'placement of preview image',
    link: 'placement of link',
    },
    },
    },
    },
    ];
    await sdk.requestAds(adUnits);

    Analytics

    Track Events

    AiactivSDK.track(event: String, properties: Object?)

    To track an event, you need to call the AiactivSDK.track() method and pass in two parameters: event and properties.

    • The event parameter is a string to name the event, for example: "Post view", "Sign up", "Purchase", etc.
    • The properties parameter is an object to contain detailed information about the event, for example: post title, product type, order value, etc.
    // Create an object to contain the properties of the event
    const postViewEventProperties = {
    title: 'Post Title',
    category: 'Category 1, Category 2',
    keyword: 'Keyword 1, Keyword 2, ...',
    };
    // Track the event "Post view" with the properties created
    AiactivSDK.track('Post view', postViewEventProperties);

    Identify Events

    AiactivSDK.identify(userId: String, traits: Object?)

    To identify a user, you need to call the AiactivSDK.identify() method and pass in one parameter: userId.

    • The userId parameter is a string to identify your user, for example: "PartnerUserID-01".
    • You can also pass in another object to contain additional information about the user, for example: user name, user type, etc.
    // Create an object to contain the properties of the user
    const userTraits = {
    userName: "Username 1",
    userType: "Normal",
    phoneNumber: "+84909090909", // Optinal
    phoneNumberHashed: "0e0425233daa5d0772dce7bf6af4c01ab00179a8e1d3c03ecb6ff0e8ce2daa72", // Optinal - SHA256 Hash
    ...
    }
    // Identify user with user ID and properties created
    AiactivSDK.identify("PartnerUserID-01", userTraits)
    // Create an object to contain the properties of the user
    const userTraits = {
    userName: "Username 1",
    userType: "Normal",
    phoneNumber: "+84909090909", // Optinal
    phoneNumberHashed: "0e0425233daa5d0772dce7bf6af4c01ab00179a8e1d3c03ecb6ff0e8ce2daa72", // Optinal - SHA256 Hash
    ...
    }
    // Identify user without user ID and properties created
    AiactivSDK.identify(userTraits)

    Traits recommended for Analytics identify

    TRAITTYPEDESCRIPTION
    addressObjectStreet address of a user optionally containing: city, country, postalCode, state, or street
    ageNumberAge of a user
    avatarStringURL to an avatar image for the user
    birthdayDateUser’s birthday
    companyObjectCompany the user represents, optionally containing: name(String), id (String or Number), industry (String), employee_count (Number) or plan (String)
    createdAtDateDate the user’s account was first created. Segment recommends using ISO-8601 date strings.
    descriptionStringDescription of the user
    emailStringEmail address of a user
    firstNameStringFirst name of a user
    genderStringGender of a user
    idStringUnique ID in your database for a user
    lastNameStringLast name of a user
    nameStringFull name of a user. If you only pass a first and last name Segment automatically fills in the full name for you.
    phoneStringPhone number of a user
    titleStringTitle of a user, usually related to their position at a specific company. Example: “VP of Engineering”
    usernameStringUser’s username. This should be unique to each user, like the usernames of Twitter or GitHub.
    websiteStringWebsite of a user
    deviceIdStringID if user's device

    Author

    AiACTIV TECH, tech@aiactiv.io

    License

    AiactivUniversalSDK is available under the MIT license. See the LICENSE file for more info.