Skip to content

Commit

Permalink
Adding support for ad vendor Affinity (#38534)
Browse files Browse the repository at this point in the history
* Added support for adtype Affinity
 On branch main
 Your branch is up to date with 'origin/main'.

 Changes to be committed:
	new file:   3p/vendors/affinity.js
	modified:   ads/_config.js
	modified:   ads/ads.extern.js
	new file:   ads/vendors/affinity.js
	new file:   ads/vendors/affinity.md
	modified:   examples/amp-ad/ads.amp.html
	modified:   extensions/amp-ad/amp-ad.md

* Linted the code
 On branch affinity_adtype_master
 Changes to be committed:
	modified:   3p/vendors/affinity.js
	modified:   ads/ads.extern.js
	modified:   ads/vendors/affinity.js

* Ran AMP Prettify
 On branch affinity_adtype_master
 Your branch is up to date with 'origin/affinity_adtype_master'.

 Changes to be committed:
	modified:   ads/vendors/affinity.md

Co-authored-by: github-01-affinity <github-01@affinity.com>
  • Loading branch information
affinity-admin and github-01-affinity committed Nov 25, 2022
1 parent d5bdbc6 commit 3f47d46
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 3p/vendors/affinity.js
@@ -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 {affinity} from '#ads/vendors/affinity';

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

window.draw3p = draw3p;
5 changes: 5 additions & 0 deletions ads/_config.js
Expand Up @@ -286,6 +286,11 @@ const adConfig = jsonConfiguration({
renderStartImplemented: true,
},

'affinity': {
prefetch: 'https://securepubads.g.doubleclick.net/tag/js/gpt.js',
preconnect: 'https://cdn4-hbs.affinitymatrix.com',
},

'aja': {
prefetch: [
'https://cdn.as.amanad.adtdp.com/sdk/asot-amp.js',
Expand Down
11 changes: 11 additions & 0 deletions ads/ads.extern.js
Expand Up @@ -319,6 +319,17 @@ window.andbeyond.initAmp = function (
extras
) {};

// affinity.js
window.affinity = {};
window.affinity.initAMP = function (global, data) {};
data.width;
data.height;
data.adtype;
data.adslot;
data['multi-size'];
data.jsontargeting;
data.extras;

// adreactor.js
data.zid;
data.pid;
Expand Down
28 changes: 28 additions & 0 deletions ads/vendors/affinity.js
@@ -0,0 +1,28 @@
import {loadScript, validateData} from '#3p/3p';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function affinity(global, data) {
validateData(
data,
['width', 'height', 'adtype', 'adslot'],
['multi-size', 'jsontargeting', 'extras']
);
loadScript(
global,
'https://securepubads.g.doubleclick.net/tag/js/gpt.js',
() => {
loadScript(
global,
'https://cdn4-hbs.affinitymatrix.com/amp/v2022/amp.js',
() => {
(function () {
window.affinity.initAMP(global, data);
})();
}
);
}
);
}
24 changes: 24 additions & 0 deletions ads/vendors/affinity.md
@@ -0,0 +1,24 @@
# Affinity

Adtype Affinity support for AMP

## Example

```html
<amp-ad
width="300"
height="250"
type="affinity"
data-adtype="banner"
data-adslot="AFFINITY_AMP_TEST_300x250"
>
</amp-ad>
```

## Configuration

- `data-adtype`: (Mandatory) Type of the adformat
- `data-adslot`: (Mandatory) Name of of adslot
- `data-multi-size`: (Optional) Multi-size support
- `data-jsontargeting`: (Optional) Targeting related paramterers
- `data-extras`: (Optional) Extra data
5 changes: 5 additions & 0 deletions examples/amp-ad/ads.amp.html
Expand Up @@ -212,6 +212,7 @@
<option>advertserve</option>
<option>adyoulike</option>
<option>affiliateb</option>
<option>affinity</option>
<option>aja</option>
<option>amoad</option>
<option>amplified</option>
Expand Down Expand Up @@ -941,6 +942,10 @@ <h2>Affiliate-B</h2>
<amp-ad width="300" height="250" type="affiliateb" data-afb_a="l44x-y174897c" data-afb_p="g2m" data-afb_t="i">
</amp-ad>

<h2>Affinity</h2>
<amp-ad width="300" height="250" type="affinity" data-adtype="banner" data-adslot="AFFINITY_AMP_TEST_300x250">
</amp-ad>

<h2>AJA</h2>
<amp-ad width="300" height="250" type="aja" layout="responsive" data-asi="xWc2iVRZR">
</amp-ad>
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/amp-ad.md
Expand Up @@ -299,6 +299,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
- [AdvertServe](../../ads/vendors/advertserve.md)
- [Adyoulike](../../ads/vendors/adyoulike.md)
- [Affiliate-B](../../ads/vendors/affiliateb.md)
- [Affinity](../../ads/vendors/affinity.md)
- [AJA](../../ads/vendors/aja.md)
- [AMoAd](../../ads/vendors/amoad.md)
- [Andbeyond](../../ads/vendors/andbeyond.md)
Expand Down

0 comments on commit 3f47d46

Please sign in to comment.