Documentation

đź’ˇ Why install our sdk ?

Light, easy to install and without any impact on the performance of your sites, our sdk is very useful :

– To ease your integrations related to the usage of the first-id identifier (Adserver, adtech Stack..)
– to ease the integrations of your partners (dmp, external prebid wrappers…)
– To allow the tracking of ad campaigns based on the first-id identifier (attribution/measure)
– to be assured to profit from the latest functionalities in the first-id product

URL


the SDK is available in a normal and minified version on our preprod and production environnement
(please note that the preprod version of the sdk may contain beta features that are not always safe to install on your production sites)

    Preprod :

    •  minified  https://cdn.first-id.fr/sdk/loader/loader.min.js
    •  normal  https://cdn.first-id.fr/sdk/loader/loader.js

    Production :

    • minified  https://cdn.first-id.fr/sdk/loader/loader.min.js
    • normal  https://cdn.first-id.fr/sdk/loader/loader.js

    Cache


    To avoid loading the SDK every time, our CDN is sending cache headers.

    The loader had a 1h cache, the SDK has a 1 year cache.
    The loader is in charge of changing the version od the SDK that is called.

    Installation


    ⚠️ IMPORTANT ⚠️

    the sdk must be called before the initialisation of your adstack, in order that all ressources are available before the activation of its fonctionnalities

    ​in the same way, the SDK must be called ONLY IF the user has given his consent, and after it ha been given.

    ​

    The SDK is composed in two parts :

    • The loader : It is really light for optimized loading. It will load the SDK and the loading callbacks
    • The SDK : The SDK itself containing all the methods.


    Exemple d’installation (avec l’url de preprod pour test, vous pourrez changer pour l’url de prod pour passer en production) : 

    <script type = "text/javascript" defer src = "https://cdn.first-id.fr/sdk/loader/loader.min.js" > < /script>

    <script type = "text/javascript" >
    // create firstId SDK configuration
    window.firstId = window.firstId || {
    callbacks: [],
    debug: true, // by default debug mode is on false. Debug mode will be enable log message in console
    cookieName: 'firstId' // by default the SDK will expect find a cookie with name "firstId" where the FirstID value is store. You can override the cookie name (if you store the FirstID in another cookie name) with the config key "cookieName"
    };

    // register callback will be call when SDK load
    // callback will be call in same order as push in array
    window.firstId.callbacks.push(() => console.log('FirstID is loaded !'))


    window.firstId.callbacks.push(() => {
    // you can use firstID with 2 ways :

    // Built a new instance of SDK
    let fid = new FirstIdSdk();

    // call some method
    console.log(fid.getVersion());

    // or you can use the global var FIRSTID
    console.log(FIRSTID.getVersion());

    // to read the FirstID :
    try {
    let firstIdValue = fid.getId();
    } catch (e) {
    // catch error
    if (e.code === 'FirstIdCookieNotFound') {
    // the cookie specify in config was nos foud
    }

    if (e.code === 'FirstIdEmptyValue') {
    // the cookie was found, but the value if empty
    }
    }
    }) </script>

    Doc Js


    En suivant ce lien, vous pouvez retrouver la JS Doc du SDK