Features Ad Serving

Native Ad Serving

ad placement design A native ad is different from a standard advertisement. It blends in with other contents on the page. Example: a sponsored link in between other organic links on your page, a promotional post in your blog or a thread in your forum, or text link ads in email newsletter. Additionally, you can use native ad serving to address ad blocking issues with third-party requests.

How It Works

You can integrate our ad serving capability into your own product and application natively. Instead of pasting the HTML/JavaScript ad tag into your website, you can make a direct ad request to our ad serving API to fetch an ad. The result from the ad server is in XML or JSON format with the individual ad components: the ad ID, dimension, ad tag and tracking code.

Your app can then extract and further process the XML/JSON result. You can display the ad in any custom way that is native and suitable for your interface or application. By displaying ads natively with server-to-server requests, you can work around ad blockers because there is no direct request from the user's browser to our ad servers.

Technical Integration

If the request is made from your server then the client's IP might need to be passed along for geo-targeting to work. Please contact us for more technical details when you are ready to test or integrate this ad serving method.

If your site requires all externally-sourced SCRIPT tags to have a hash for Subresource Integrity, you can use a client-side JSON ad request to avoid enforcing a hash on a dynamic ad request. The result of each ad request from AdSpeed adserver is dynamic and not static. The reason is because it actually contains the ad chosen from the zone, which is different each time.

Sample Code - Client-side JSON

<div id="MyAdContainer"></div>

<script type="text/javascript">
 $(document).ready(function () {
  $.getJSON('https://g.adspeed.net/ad.php?do=json&zid=XXXX&oid=YYYY&wd=-1&ht=-1&target=_blank&cb='+Math.random(), function (j) {
   $('#MyAdContainer').append(j.AdServing.AdCode);
   $('#MyAdContainer').append(j.AdServing.TrackerCode);
 });
});
</script>
For third-party ad tags that depend on document.write()
<div id="MyAdContainer"></div>

<script src="https://g.adspeed.net/js/adspeed_jsonframe.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
  $.getJSON('https://g.adspeed.net/ad.php?do=json&zid=XXXX&oid=YYYY&wd=-1&ht=-1&target=_blank&cb='+Math.random(),function(j){
   AdSpeed_json('MyAdContainer',j);
  });
 });
</script>

Sample Code - Server-side XML/JSON

<?php
/**
* Fetch an ad from the adserver
* @param string URL
* @return string
*/
function requestAd($pURL) {
	$vCURL = curl_init($pURL);
	curl_setopt($vCURL,CURLOPT_USERAGENT,'AdSpeedNativeAdServer-Server2ServerRequester');
	curl_setopt($vCURL,CURLOPT_RETURNTRANSFER,1);
	$vResult = curl_exec($vCURL);
	curl_close($vCURL);
	return $vResult;
}

// Example 1: JSON
$vResult = requestAd('https://g.adspeed.net/ad.php?do=json&zid=XXXX&oid=YYY&wd=-1&ht=-1&target=_blank&cb='.time());
$vJSON = json_decode($vResult);
echo("\n\n<h4>Request JSON from AdSpeed AdServer</h4>\n\n");
echo($vJSON->AdServing->AdCode);
echo($vJSON->AdServing->TrackerCode);

// Example 2: XML
$vResult = requestAd('https://g.adspeed.net/ad.php?do=xml&zid=XXXX&oid=YYY&wd=-1&ht=-1&target=_blank&cb='.time());
$vXML = simplexml_load_string($vResult);
echo("\n\n<h4>Request XML from AdSpeed AdServer</h4>\n\n");
echo((string)trim($vXML->AdCode)); // data w/in CDATA
echo($vXML->TrackerCode->div->asXML());

?>
Print Was this helpful? Yes / No

Other Articles in Ad Serving

Features of our ad server that display ads to your viewers, record ad metrics like impressions and clicks.

Cannot find an answer for your question? Ask our Customer Care team

Related