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
| Property | Type | Required? | Description |
|---|---|---|---|
| p | array of objects | y | placements (see Placement Object Properties below) |
| ukey | string | n | the userKey |
| ip | string | n | the IP address |
| ref | string | n | the referrer |
| url | string | n | the site URL |
| t | long | n | UNIX epoch timestamp (seconds or milliseconds) |
| kw | array of strings | n | keywords |
| nt | boolean | n | DNT enabled |
| b | object | n | blocked items |
| bf | boolean | n | bot-filtering enabled |
Placement Object Properties
| Property | Type | Required? | Description |
|---|---|---|---|
| n | string | y | network ID |
| s | int | y | site ID |
| t | array of ints | y | ad type IDs |
| d | string | n | div name (defaults to "kevel") |
| z | array of ints | n | zone IDs |
| c | int | n | campaign ID |
| f | int | n | flight ID |
| a | int | n | ad ID |
| u | string | n | click URL |
| p | object | n | custom properties |
| ck | object | n | content 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:
-
You will need to first host the creative image with Kevel.
-
Create a new creative using the a4a document code from the above section.
-
Replace the
srcof 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"... -
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 usehttps://or//as your protocol for<amp-pixel>elements. Amp will return an error ifhttp://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.
Updated 9 months ago
