forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for ad vendor Affinity (ampproject#38534)
* 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 <[email protected]>
- Loading branch information
1 parent
d5bdbc6
commit 3f47d46
Showing
7 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {affinity} from '#ads/vendors/affinity'; | ||
|
||
init(window); | ||
register('affinity', affinity); | ||
|
||
window.draw3p = draw3p; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
})(); | ||
} | ||
); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters