Skip to content

Commit

Permalink
✨ Pixad Ad Integration | New (#39744)
Browse files Browse the repository at this point in the history
* Pixad Ad Integration

* updated trailing whitespace.

* fix

* Update pixad.js

* Update integration.js

* Update amp-ad.md

* Update pixad.md
  • Loading branch information
fatihkaya84 authored Jan 24, 2024
1 parent 0e60e0c commit ef8eac7
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ import {openadstream} from '#ads/vendors/openadstream';
import {openx} from '#ads/vendors/openx';
import {opinary} from '#ads/vendors/opinary';
import {outbrain} from '#ads/vendors/outbrain';
import {pixad} from '#ads/vendors/pixad';
import {pixels} from '#ads/vendors/pixels';
import {playstream} from '#ads/vendors/playstream';
import {plista} from '#ads/vendors/plista';
Expand Down Expand Up @@ -488,6 +489,7 @@ register('openadstream', openadstream);
register('openx', openx);
register('opinary', opinary);
register('outbrain', outbrain);
register('pixad', pixad);
register('pixels', pixels);
register('playstream', playstream);
register('plista', plista);
Expand Down
12 changes: 12 additions & 0 deletions 3p/vendors/pixad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// src/polyfills.js must be the first import.
import '#3p/polyfills';

import {register} from '#3p/3p';
import {draw3p, init} from '#3p/integration-lib';

import {pixad} from '#ads/vendors/pixad';

init(window);
register('pixad', pixad);

window.draw3p = draw3p;
2 changes: 2 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,8 @@ const adConfig = jsonConfiguration({
consentHandlingOverride: true,
},

'pixad': {},

'pixels': {
prefetch: 'https://cdn.adsfactor.net/amp/pixels-amp.min.js',
clientIdCookieName: '__AF',
Expand Down
37 changes: 37 additions & 0 deletions ads/vendors/pixad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {validateData, writeScript} from '#3p/3p';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function pixad(global, data) {
validateData(data, ['adNetwork', 'adPublisher', 'adTypeId']);
global._pixad = global._pixad || {
publisher: data['adNetwork'],
adNetwork: data['adPublisher'],
adTypeId: data['adTypeId'],
host: `static.cdn.pixad.com.tr`,
prefix: `px`,
};

if (global._pixad.publisher.indexOf('adm-pub') != -1) {
global._pixad.host = `static.cdn.admatic.com.tr`;
global._pixad.prefix = `adm`;
}

const ins = global.document.createElement('ins');
ins.setAttribute('data-publisher', global._pixad.publisher);
if (global._pixad.adTypeId == 'standard') {
ins.setAttribute('data-ad-size', `[[${data.width},${data.height}]]`);
}
ins.setAttribute('data-ad-network', global._pixad.adNetwork);
ins.setAttribute('data-ad-type-id', global._pixad.adTypeId);
ins.setAttribute('class', `${global._pixad.prefix}-ads-area`);
global.document.getElementById('c').appendChild(ins);
ins.parentNode.addEventListener(
'eventAdbladeRenderStart',
global.context.renderStart()
);

writeScript(global, `https://${global._pixad.host}/showad/showad.min.js`);
}
51 changes: 51 additions & 0 deletions ads/vendors/pixad.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Pixad

## Example of Pixad's model implementation

### Basic

```html
<amp-ad
type="pixad"
width="300"
height="250"
data-ad-type-id="standard"
data-ad-network="px-pub-6514176248"
data-ad-publisher="654b7d501cd4137ca98e020d">
</amp-ad>
```

### Sticky Ad

```html
<amp-sticky-ad layout="nodisplay">
<amp-ad
type="pixad"
width="320"
height="100"
data-ad-type-id="778130932"
data-ad-network="px-pub-6514176248"
data-ad-publisher="654b7d501cd4137ca98e020d">
</amp-ad>
</amp-sticky-ad>
```

Note that `<amp-sticky-ad />` component requires the following script to be included in the page:

```html
<script
async
custom-element="amp-sticky-ad"
src="https://cdn.ampproject.org/v0/amp-sticky-ad-1.0.js"
></script>
```

## Configuration

For details on the configuration semantics, see [Pixad documentation](https://developer.pixad.com.tr/).

### Required parameters

- `data-ad-network`: Network ID
- `data-ad-publisher`: Publisher ID
- `data-ad-type-id`: Model ID
11 changes: 11 additions & 0 deletions examples/amp-ad/ads.amp.esm.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
<option>openx</option>
<option>opinary</option>
<option>outbrain</option>
<option>pixad</option>
<option>pixels</option>
<option>plista</option>
<option>polymorphicads</option>
Expand Down Expand Up @@ -1705,6 +1706,16 @@ <h2>Outbrain widget</h2>
data-testMode="true">
</amp-embed>

<h2>Pixad</h2>
<amp-ad
type="pixad"
width="300"
height="250"
data-ad-type-id="standard"
data-ad-network="px-pub-6514176248"
data-ad-publisher="654b7d501cd4137ca98e020d">
</amp-ad>

<h2>Pixels Examples</h2>
<amp-ad width="300" height="250"
type="pixels"
Expand Down
11 changes: 11 additions & 0 deletions examples/amp-ad/ads.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
<option>openx</option>
<option>opinary</option>
<option>outbrain</option>
<option>pixad</option>
<option>pixels</option>
<option>playstream</option>
<option>plista</option>
Expand Down Expand Up @@ -1498,6 +1499,16 @@ <h2>Outbrain widget</h2>
data-styleFile="http://localhost/style.css" data-testMode="true">
</amp-embed>

<h2>Pixad</h2>
<amp-ad
type="pixad"
width="300"
height="250"
data-ad-type-id="standard"
data-ad-network="px-pub-6514176248"
data-ad-publisher="654b7d501cd4137ca98e020d">
</amp-ad>

<h2>Pixels Examples</h2>
<amp-ad width="300" height="250" type="pixels" data-origin="af" data-sid="2847717911664" data-tag="sync"
data-click-tracker="false" data-viewability="true">
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/amp-ad.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
- [Open AdStream (OAS)](../../ads/vendors/openadstream.md)
- [OpenX](../../ads/vendors/openx.md)
- [opinary](../../ads/vendors/opinary.md)
- [Pixad](../../ads/vendors/pixad.md)
- [Pixels](../../ads/vendors/pixels.md)
- [plista](../../ads/vendors/plista.md)
- [polymorphicAds](../../ads/vendors/polymorphicads.md)
Expand Down

0 comments on commit ef8eac7

Please sign in to comment.