Skip to main content

Restore ad when returning

The same advertisement that was previously displayed can be displayed when returning to the page by going back can be applied with Persist.

Persist mode does not work if the page is restored to the BF Cache of the browser.

1. Concepts

  • In the case of applying Persist, SDK stores the ad information when rendering the advertisement.

    The Ad information is stored as a separate page URL + adSlotElementId.

  • When rendering an ad slot, SDK displays the saved ad if all the conditions below are met.

    1. enablePersistAd must be set to true.
    2. The page must be loaded via go back.
    3. An Ad stored with page URL + adSlotElementId as the separator must exist.

2. Set Persist

3. Ad rendering with Persist

  • Use gladsdk.displayAd() to load advertisements.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>Hello NAM</title>
    <script async src="https://ssl.pstatic.net/tveta/libs/glad/prod/gfp-core.js"></script>
    <script>
    window.gladsdk = window.gladsdk || { cmd: [] };
    window.gladsdk.cmd.push(function () {
    window.gladsdk.setGlobalConfig({
    enablePersistAd: true,
    });
    });
    </script>
    </head>

    <body>
    <div id="division_1"></div>
    <script>
    var adSlotInfo1 = {
    adUnitId: 'p_stock',
    adSlotElementId: 'division_1',
    };

    window.gladsdk.cmd.push(function () {
    var adSlot1 = window.gladsdk.defineAdSlot(adSlotInfo1);
    gladsdk.displayAd(adSlot1);
    });
    </script>
    </body>
    </html>