Native Content-Driven Advertising Example 2

In the previous blog, I mentioned there are two approaches to do Native Content-Driven Advertising and showed you how to manually target keywords and IAB Categories. In this blog, I describe how to do it automatically using AdRelevantis Content-Analysis service.

In your page head, add the following code.

<script async src="//www.adrelevantis.com/js/dev/prebid.js"></script>
<script src="//www.adrelevantis.com/js/contentdriventag.js"></script>
<script>
  var adUnits = [
    {
      code: 'div1',
      sizes: [
        [300, 300]
      ],
      mediaTypes: {
        native: {
          title: {
            required: true
          },
          image: {
            required: true
          },
          sponsoredBy: {
            required: true
          }
        }
      },
      bids: [{
        bidder: 'adrelevantis',
        params: {
          placementId: 13232354,
          allowSmallerSizes: true
        }
      }]
    },
    {
      code: 'div2',
      sizes: [
        [300, 300]
      ],
      mediaTypes: {
        native: {
          title: {
            required: true
          },
          image: {
            required: true
          },
          sponsoredBy: {
            required: true
          }
        }
      },
      bids: [{
        bidder: 'adrelevantis',
        params: {
          placementId: 13232354,
          allowSmallerSizes: true
        }
      }]
    },
    {
      code: 'div3',
      sizes: [
        [300, 300]
      ],
      mediaTypes: {
        native: {
          title: {
            required: true
          },
          image: {
            required: true
          },
          sponsoredBy: {
            required: true
          }
        }
      },
      bids: [{
        bidder: 'adrelevantis',
        params: {
          placementId: 13232354,
          allowSmallerSizes: true
        }
      }]
    }
  ];
  
  var pbjs = pbjs || {};
  pbjs.que = pbjs.que || [];
  
  var adDivIds = ['div-1','div-2','div-3'];
  document.addEventListener("DOMContentLoaded", function(event){ adrtags("D435C107A8844E15BAA5D4A9B7D94FC5", adUnits, adDivIds); });
</script>

The code creates three ad units, each corresponds one <div> tag in the page.

<div id='div-1'>
</div>
<div id='div-2'>
</div>
<div id='div-3'>
</div>

You can put these tags anywhere you want in the page.

When the page opens, the DOMContentLoaded event handler analyzes the page content to get its IAB Categories and top keywords; the Categories and keywords are sent as request parameters; the SSP and DSP bids based on the request parameters; the matched native ads are displayed.

You can find a working example at https://github.com/ghguo/adrhb-examples/blob/master/ContentExamples/essential-french-onion-soup-native.html. Need more info? Drop us a line at <info@adrelevantis.com>.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s