Skip to content

Commit ea70b30

Browse files
✨ Add amp-ad implementation for Adserver.Online (#40434)
* Adserver.Online AMP ad integration * Unnecessary change reverted * Extensions list sorted alphabetically --------- Co-authored-by: Shihua Zheng <powerivq@users.noreply.github.com>
1 parent 2055896 commit ea70b30

File tree

6 files changed

+111
-0
lines changed

6 files changed

+111
-0
lines changed

3p/vendors/aso.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// src/polyfills.js must be the first import.
2+
import '#3p/polyfills';
3+
4+
import {register} from '#3p/3p';
5+
import {draw3p, init} from '#3p/integration-lib';
6+
7+
import {aso} from '#ads/vendors/aso';
8+
9+
init(window);
10+
register('aso', aso);
11+
12+
window.draw3p = draw3p;

ads/_config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ const adConfig = jsonConfiguration({
317317
renderStartImplemented: true,
318318
},
319319

320+
'aso': {
321+
renderStartImplemented: true,
322+
},
323+
320324
'amoad': {
321325
prefetch: ['https://j.amoad.com/js/a.js', 'https://j.amoad.com/js/n.js'],
322326
preconnect: [

ads/vendors/aso.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {loadScript, validateData} from '#3p/3p';
2+
3+
import {tryParseJson} from '#core/types/object/json';
4+
5+
/**
6+
* @param {!Window} global
7+
* @param {!Object} data
8+
*/
9+
export function aso(global, data) {
10+
validateData(data, ['zone'], ['host', 'attr']);
11+
12+
const host = data.host || 'media.aso1.net';
13+
14+
global._aso = {
15+
onempty: () => global.context.noContentAvailable(),
16+
onload: (a) =>
17+
global.context.renderStart({
18+
width: a.width,
19+
height: a.height,
20+
}),
21+
};
22+
23+
loadScript(global, `https://${host}/js/code.min.js`, () =>
24+
loadAd(global, data)
25+
);
26+
}
27+
28+
/**
29+
* @param {!Window} global
30+
* @param {!Object} data
31+
*/
32+
function loadAd(global, data) {
33+
const attr = tryParseJson(data['attr']) || {};
34+
attr._amp = 1;
35+
36+
global._ASO.loadAd('c', data.zone, true, {
37+
attr,
38+
});
39+
}

ads/vendors/aso.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Adserver.Online
2+
3+
## Example
4+
5+
### Basic
6+
7+
```html
8+
<amp-ad
9+
type="aso"
10+
width="300"
11+
height="250"
12+
data-zone="158819">
13+
</amp-ad>
14+
```
15+
16+
### Sticky Ad
17+
18+
```html
19+
<amp-sticky-ad layout="nodisplay">
20+
<amp-ad
21+
type="aso"
22+
width="320"
23+
height="100"
24+
data-zone="158829">
25+
</amp-ad>
26+
</amp-sticky-ad>
27+
```
28+
29+
Note that `<amp-sticky-ad />` component requires the following script to be included in the page:
30+
31+
```html
32+
<script
33+
async
34+
custom-element="amp-sticky-ad"
35+
src="https://cdn.ampproject.org/v0/amp-sticky-ad-1.0.js"
36+
></script>
37+
```
38+
39+
## Configuration
40+
41+
For details on the configuration, please see [Adserver Documentation](https://adserver.online/article/amp).
42+
43+
### Required parameters
44+
45+
- `data-zone`
46+
47+
### Optional parameters
48+
49+
- `data-host` - custom media domain
50+
- `data-attr` - custom attributes, JSON-string. Example: `data-attr='{"foo": "bar"}'`

examples/amp-ad/ads.amp.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
<option>appmonsta</option>
226226
<option>appnexus</option>
227227
<option>appvador</option>
228+
<option>aso</option>
228229
<option>atomx</option>
229230
<option>avantisvideo</option>
230231
<option>baidu</option>
@@ -836,6 +837,10 @@ <h2>AppVador</h2>
836837
<amp-ad width="320" height="180" type="appvador" data-id="8c328a2daa6f9ce4693f57246cd86e0a">
837838
</amp-ad>
838839

840+
<h2>Adserver.Online</h2>
841+
<amp-ad width="300" height="250" type="aso" data-zone="158819">
842+
</amp-ad>
843+
839844
<h2>Atomx</h2>
840845
<amp-ad width="300" height="250" type="atomx" data-id="1234">
841846
</amp-ad>

extensions/amp-ad/amp-ad.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
282282
- [Ads2Bid](../../ads/vendors/ads2bid.md)
283283
- [AdSense](../../ads/google/adsense.md)
284284
- [AdSensor](../../ads/vendors/adsensor.md)
285+
- [Adserver.Online](../../ads/vendors/aso.md)
285286
- [AdServSolutions](../../ads/vendors/adservsolutions.md)
286287
- [AdsLoom](../../ads/vendors/adsloom.md)
287288
- [AdsNative](../../ads/vendors/adsnative.md)

0 commit comments

Comments
 (0)