Yield Manager - Advanced Integrations

Yield Manager - Advanced Integrations

Yield Manager - Advanced Integrations

Below you will find more advanced integrations using HTML units, where there is no UI for it yet.

CPM Adjustments

<script type="text/javascript">
(function() {
    var biddersCPMAdjustment = {
        amx: .89,
        appnexus: .95,
        medianet: .99,
        minutemedia: .94,
        onetag: .94,
        rise: .96,
        sharethrough: .93,
        triplelift: .95,
    }
    
    pbjs.bidderSettings = {
        standard: {
            storageAllowed: true
        }
    }

    Object.keys(biddersCPMAdjustment).forEach(function(bidder) {
        var multiplier = biddersCPMAdjustment[bidder];
        (window.pbjs.bidderSettings[bidder] = window.pbjs.bidderSettings[bidder] || {}).bidCpmAdjustment = function(bidCpm, bid) {
            return bidCpm * multiplier
        }
    });
})();
</script>

Targeting / Key-Values

<script type="text/javascript">
    // page level targeting
    googletag.cmd.push(function() {
        googletag.pubads().setTargeting('ay_ym', 'on');
    });

    // slot level targeting
    ayManagerEnv.onEvent("afterDefineSlot", function(adUnitInstanceCode, slot) {
        var targetingMap = {
          'pos': adUnitInstanceCode.replace(/__ayManagerEnv__.+$/, ''),
        }

        slot.updateTargetingFromMap(targetingMap)
    });
</script>

Interstitial and Out-Of-Page Slot

There are currently no UI options for configuring interstitial and out-of-page slots, but they can be added with a simple script tag in an HTML unit, see examples below.

Interstitial

<script type="text/javascript">
    googletag.cmd.push(function() {
        var interstitialSlot = googletag.defineOutOfPageSlot('/6355419/Travel/Europe/France/Paris', googletag.enums.OutOfPageFormat.INTERSTITIAL);
        if (interstitialSlot) {
            interstitialSlot.addService(googletag.pubads());
            googletag.pubads().refresh([interstitialSlot]);
        }
    });
</script>

Out Of Page

<script type="text/javascript">
    googletag.cmd.push(function() {
        var slot = 'OOP-1';
        var wrapper = document.createElement('div');
        wrapper.id = slot;
        document.body.appendChild(wrapper);
        var oopSlot = googletag.defineOutOfPageSlot('/6355419/Travel/Europe/France/Paris', slot).addService(googletag.pubads());
        googletag.pubads().refresh([oopSlot]);
    });
</script>

Lazy Load Offset

The current default value is an offset of 1400. Meaning, all ad units inside the viewport and 1400px below it are rendered.

Note: This code needs to go into the "Pre-Script (Advanced)" field under "Settings".

// Fixed Value
window.ayManagerEnv.customLazyLoadOffset = 1400;

// Dynamic Value
var viewportMultiplier = 1;
var deviceMultiplier = 1;
if ((window.innerWidth || document.documentElement.clientWidth) < 992) deviceMultiplier = 2;
var viewportHeight = window.innerHeight;
window.ayManagerEnv.customLazyLoadOffset = Math.floor((viewportHeight * viewportMultiplier) * deviceMultiplier);

Sticky Close Button

This is an example on how a sticky footer unit with a close button can be integrated.

Please make sure to replace StickyBottom with the identifier name of your sticky placement, which is set to manual placement.

<div id="aymStickyFooter" class="empty">
    <div data-ay-manager-id="StickyBottom">
        <script type="text/javascript">
            window.ayManagerEnv = window.ayManagerEnv || { cmd : []};
            window.ayManagerEnv.cmd.push(function() {
                ayManagerEnv.display("StickyBottom");
            });
        </script>
    </div>
    <div id="aymStickyFooterClose" onclick="window.ayManagerEnv.destroy(['StickyBottom']); try { document.getElementById('aymStickyFooter').remove(); } catch(e) {};">X</div>
</div>
<script>
    googletag.cmd.push(function() {
        googletag.pubads().addEventListener("slotRenderEnded", function(event) {
            const slot = event.slot;
            const elemId = slot.getSlotElementId();
            if (elemId.toLowerCase().indexOf("sticky") !== -1) {
                const sticky = document.getElementById("aymStickyFooter");
                if (event.isEmpty) {
                    if (sticky.classList.contains("empty")) return;
                    sticky.classList.add("empty");
                } else {
                    sticky.classList.remove("empty");
                }
            }
        });
    });
</script>
<style>
    #aymStickyFooter.empty {
        padding: 0;
    }
    #aymStickyFooter.empty #aymStickyFooterClose {
        display: none;
    }
    #aymStickyFooter {
        display: block;
        position: fixed;
        bottom: 0px;
        background-color: white;
        border-top: 1px solid rgb(239, 239, 239);
        z-index: 150;
        padding: 5px 5px 0;
        transform: translate(-50%);
        left: 50%;
    }
    #aymStickyFooterClose {
        position:absolute;
        top:-20px;
        right:0px;
        background-color: white;
        font-family: sans-serif;
        float: right;
        text-align: center;
        border-top: 1px solid gray;
        border-left: 1px solid gray;
        border-radius: 50% 0% 0% 0%;
        padding: 3px;
        height: 20px;
        width: 20px;
        cursor: pointer;
        line-height: 10px;
        font-size: 14px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
</style>

Advertiser Refresh Exclusion

All advertisers are allowed to refresh by default. Adding IDs to include, will only allow the refresh for the listed advertiser IDs. Alternatively, the refresh can be disabled for the ones added to exclude.

<script type="text/javascript">
    ayManagerEnv.settings.yieldScriptSettings.disableRefreshForDirectCampaign = {
        enabled: true,
        advertiserIds: {
            include: [484548, 48468], // allowed to refresh
            exclude: [], // not allowed to refresh
        }
    }
</script>

Fluid Size

<script type="text/javascript">
    ayManagerEnv.onEvent("beforeDefineSlot", function(adUnitInstanceCode, slotArgs) {
        if (adUnitInstanceCode.includes('native')) {
            slotArgs.size.push('fluid');
        }
    });
</script>

IntentIQ

Note: The Prebid modules userId, pubProvidedIdSystem (PubProvided ID) and unifiedIdSystem (Unified ID) are required.

<script type="text/javascript">
(function() {
    var partnerId = 0; // replace with your partner id
    var revenueBias = 1; // can be set based on the partner's revenue share, e.g. 0.9 to subtract 10% revenue share
    var reportGroupToCustomDimension = 'custom_8'; // can be set to any custom_X dimension, to have the IntentIQ AB group reported to the AY analytics

    var intentIq;
    var script = document.createElement('script');
    script.src = 'https://' + ayManagerEnv.versionInfo.entityId + '.ay.delivery/IIQUniversalID.js';
    script.onload = function() {
        intentIq = new window.IntentIqObject({
            partner: partnerId,
            pbjs: window[ayManagerEnv.settings.prebidSettings.prebidScript.windowName],
            timeoutInMillis: 200,
            manualWinReportEnabled: true,
            ABTestingConfigurationSource: 'percentage',
            abPercentage: 95,
            domainName: window.location.hostname.replace('www.', ''),
            browserBlackList: 'Chrome'
        });
        window['intentIq_' + partnerId] = intentIq;

        if (reportGroupToCustomDimension) {
            var currentTestGroup = intentIq.intentIqConfig.abTesting.currentTestGroup;
            var groupNames = intentIq.intentIqConfig.abTesting.groupNames;
            for (var group of Object.keys(groupNames)) {
                if (groupNames[group] === currentTestGroup) {
                    window.assertive.analytics.custom[reportGroupToCustomDimension] = group;
                    break;
                }
            }
        }
    }
    document.head.appendChild(script);

    window.addEventListener('assertive_logImpression', function(event) {
        if (!intentIq || typeof intentIq.reportExternalWin !== 'function') {
            return;
        }
        const payload = event.data.payload;
        if (payload.unfilled || payload.sourceInternal !== 'gpt') {
            return;
        }

        payload.revenueBias = revenueBias;

        var reportData;
        if (payload.preBidWon) {
            var cpm = payload.highestBid.cpm;
            if (cpm <= 0 || cpm > 100) {
                  return;
            }
            reportData = {
                biddingPlatformId: 1,
                // partnerAuctionId: xxxxxxxx-xxxxxx-xxxxxx,
                bidderCode: payload.highestBid.bidderCode,
                prebidAuctionId: payload.highestBid.auctionId,
                cpm,     
                currency: payload.highestBid.currency, 
                originalCpm: payload.highestBid.originalCpm,
                originalCurrency: payload.highestBid.originalCurrency,
                status: payload.highestBid.status,
                placementId: payload.highestBid.adUnitCode,
            }
        } else if (payload.apsWon) {
            reportData = {
                biddingPlatformId: 2,
            }
        } else {
            reportData = {
                biddingPlatformId: 3,
            }
        }
        intentIq.reportExternalWin(reportData);
    });
})();
</script>
This website uses cookies.   Learn more