We’ve migrated our documentation to a new site, which means some URLs have changed.
Audience

Example 8a - Using the default renderer

This example renders all kinds of ads using the default ad renderer (cX.defaultAdRenderer()).

 Ad tag to be placed on the publisher page:

<!-- Ad tag begin -->
<div id="insertAdSpaceBeforeThis_000000000077eca4" style="display:none"></div>
<script type="text/javascript">
    (function() { try { var scriptEl = document.createElement('script'); scriptEl.type = 'text/javascript'; scriptEl.async = 'async';
    scriptEl.src = ('https:' == document.location.protocol) ? 'https://scdn.cxense.com/cx.js' : 'http://cdn.cxense.com/cx.js';
    var targetEl = document.getElementsByTagName('script')[0]; targetEl.parentNode.insertBefore(scriptEl, targetEl); } catch (e) {}; }());
</script>
<script type="text/javascript">
    var cX = cX || {}; cX.callQueue = cX.callQueue || [];
    cX.callQueue.push(['insertAdSpace', {
        adSpaceId:'000000000077eca4',
        renderTemplateUrl: 'TemplateExample8a.html',
        width: 728, height: 90
 }]);
</script>
<!-- Ad tag end end -->

 

Template code "TemplateExample8a.html":

<!DOCTYPE html>
<html>
<head>
    <title>Using the default renderer for all ad types</title>
    <style type="text/css">
        html, body { margin: 0; padding: 0; }
        .template { display: none; }
    </style>
</head>
<body>
    <!-- Include the cx.js script -->
    <script type="text/javascript" src="http://cdn.cxense.com/cx.js"></script>
    <!-- The ads are inserted into this div: -->
    <div id="adSpace">
        <!-- This is the invisible template that is used to instanciate the ad -->
        <div id="adsTemplate" class="template">
        <!--%
        var adSpace = data.searchResult.spaces[0];
        for (var i = 0; i < adSpace.ads.length; i++) {
            var ad = adSpace.ads[i];
            cX.defaultAdRenderer(adSpace, ad);
        }
        %-->
        </div>
    </div>
 
    <!-- Insert AdSpace -->
    <script type="text/javascript">
        var cX = cX || {}; cX.callQueue = cX.callQueue || [];
        cX.callQueue.push(['insertAdSpace', {
            templateElementId: 'adsTemplate',
            targetElementId: 'adSpace',
            forwardHashArgs: true
        }]);
    </script>
</body>
</html>

 

JSON wire data:

{ "searchResult": {
    "pageNumber": 0,
    "contentBaseURL": "http://c803413.r13.cf2.rackcdn.com/",
    "actionBaseURL": "http://adserver.sandbox.cxad.cxense.com/adserver/action",
    "previous": "",
    "next": "",
    "spaces": [
        {
            "id": "000000000077eca4",
            "adUnitWidth": 728, "adUnitHeight": 90,
            "isVerticallyOriented": false,
            "ads": [
                {
                    "id" :"000000000077e2fe",
                    "creative": {
                        "type": "com.fastsearch.admomentum.plugins.imagecreative.feature.ImageCreativeFeature",
                        "formatVersion": "1.0",
                        "id": "000000000077e35e",
                        "contentServerId": "d39f0f8c77614aba5b65542f5c01318304474bd307c26b2300a98a6075c5bcbe.gif",
                        "source": "http://c803413.r13.cf2.rackcdn.com/d39f0f8c77614aba5b65542f5c01318304474bd307c26b2300a98a6075c5bcbe.gif",
                        "description": "Amazon AD",
                        "filename": "amazon.gif",
                        "spec": {
                            "height": 90,
                            "width": 728
                        },
                        "destinationUrl": "http://www.amazon.com"
                    },
                    "contextToken": "AAAAAAB37KQAAAAAAHfi)gAAAAAAd*Ne)sygKvGhQj*NRfiZPUl8Dw4wHzAuMDAxMjU1H0VVUgAAAAEAAAE4VzJmIQAAAAA(",
                    "clickUrl": "http://adserver.sandbox.cxad.cxense.com/adserver/click/AAAAAAB37KQAAAAAAHfi)gAAAAAAd*Ne)sygKvGhQj*NRfiZPUl8Dw4wHzAuMDAxMjU1H0VVUgAAAAEAAAE4VzJmIQAAAAA("
                }
            ]
        }
    ]
}}



Last updated: