AMP Ad Code

🚧

This feature is in Beta. The documentation is subject to change.

To serve AMP ads, you will need:

  • An ad placement (custom element) on an AMP page
  • In that placement, an ad request object (see details below)
  • An AMP creative saved in Kevel

AMP Ad Placement Example

<amp-ad width=300 height=250
      type="adzerk"
      data-r='{"p":[{"t":[5],"s":993150}]}'>
    <div placeholder></div>    
  </amp-ad>

You can also modify the AMP ad placement to fall back to your own data or an empty div if a request to Kevel does not return an ad:

<amp-ad width=300 height=250
      type="adzerk"
      data-r='{"p":[{"t":[5],"s":993150}]}'>
    <div placeholder></div>
    <div fallback>Fallback ad here</div>
  </amp-ad>

AMP Ad Request

The AMP ad code endpoint is:

https://e-<networkId>.adzerk.net/amp

This endpoint accepts GET requests with query parameter r whose value is a JSON string (see Request Object Properties below) and returns an AMP ad as specified in the amp4ads (a4a) spec.

Example (cURL):

curl -g https://e-2601.adzerk.net/amp?r='{"p":[{"n":2601,"t":[5],"s":262364,"a":6964330}]}'

Request Object Properties

PropertyTypeRequired?Description
parray of objectsyplacements (see Placement Object Properties below)
ukeystringnthe userKey
ipstringnthe IP address
refstringnthe referrer
urlstringnthe site URL
tlongnUNIX epoch timestamp (seconds or milliseconds)
kwarray of stringsnkeywords
ntbooleannDNT enabled
bobjectnblocked items
bfbooleannbot-filtering enabled

Placement Object Properties

PropertyTypeRequired?Description
nstringynetwork ID
sintysite ID
tarray of intsyad type IDs
dstringndiv name (defaults to "kevel")
zarray of intsnzone IDs
cintncampaign ID
fintnflight ID
aintnad ID
ustringnclick URL
pobjectncustom properties
ckobjectncontent keys

AMP Creatives: JavaScript/HTML Creatives

Javascript/HTML creatives are rendered by the /amp endpoint as-is— macros are expanded but no other templates are applied. This means that your creative content must be in the form of a valid a4a HTML document or the ad will not serve.

An example a4a document using Kevel macros to load an uploaded image:

<!doctype html>
 <html amp4ads>
  <head>
     <meta charset="utf-8">
     <script async src="https://cdn.ampproject.org/amp4ads-v0.js"></script>
     <style amp4ads-boilerplate>body{visibility:hidden}</style>
     <meta name="viewport" content="width=device-width,minimum-scale=1">
   </head>
   <body>
     <a href="{{url}}" rel="nofollow" target="_blank" title="{{title}}">
       <amp-img src="{{contentUrl}}/{{fileName}}" title="{{title}}" alt="{{title}}" width="{{width}}" height="{{height}}"></amp-img>
     </a>
     <amp-pixel src="{{impressionUrl}}"></amp-pixel>
   </body>
 </html>

Serving 3rd Party Tracking Pixels With AMP Creatives

To serve a tracking pixel with an AMP creative:

  1. You will need to first host the creative image with Kevel.

  2. Create a new creative using the a4a document code from the above section.

  3. Replace the src of the <amp-img> tag with the full path of the image hosted on Kevel. For example: <amp-img src="http://static.adzerk.net/Advertisers/5f62fffdcf2e4616a496ee7a4a191f16.jpg"...

  4. Then add an additional <amp-pixel> element for each tracking pixel that needs to serve with the ad:

<amp-pixel src="https://your.3rdparty.impression.tracking.pixel/i.jpg"></amp-pixel>

🚧

Note that you'll have to use https:// or // as your protocol for <amp-pixel> elements. Amp will return an error if http:// is used.

AMP Creatives: Image Creatives

You can upload an image to be served as an AMP ad. Note that when the image creative is served via AMP, Kevel will apply the "AMP Image Template" above to render the image as an a4a document.