Skip to content

Commit 1c9d682

Browse files
authored
✨ Add amp-ad implementation for Impactify (#40396)
* AMP ad implementation for Impactify * Remove unused import from legacy file
1 parent af62e03 commit 1c9d682

File tree

6 files changed

+108
-0
lines changed

6 files changed

+108
-0
lines changed

3p/vendors/impactify.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 {impactify} from '#ads/vendors/impactify';
8+
9+
init(window);
10+
register('impactify', impactify);
11+
12+
window.draw3p = draw3p;

ads/_config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,19 @@ const adConfig = jsonConfiguration({
672672
'imonomy': {
673673
renderStartImplemented: true,
674674
},
675+
676+
'impactify': {
677+
prefetch: 'https://ad.impactify.io/static/ad/tag.js',
678+
preconnect: [
679+
'https://ad.impactify.media',
680+
'https://dvr.impactify.media',
681+
'https://securepubads.g.doubleclick.net',
682+
'https://pubads.g.doubleclick.net',
683+
'https://secure.adnxs.com',
684+
],
685+
renderStartImplemented: true,
686+
},
687+
675688
'improvedigital': {},
676689

677690
'incrementx': {

ads/vendors/impactify.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {loadScript, validateData} from '#3p/3p';
2+
3+
import {CONSENT_STRING_TYPE} from '#core/constants/consent-state';
4+
5+
/**
6+
* @param {!Window} global
7+
* @param {!Object} data
8+
*/
9+
export function impactify(global, data) {
10+
validateData(data, ['appId', 'format', 'style']);
11+
12+
const doc = global.document;
13+
const container = doc.createElement('div');
14+
const slotId = `impactify-slot-${Math.floor(Math.random() * 10000)}`;
15+
container.id = slotId;
16+
doc.getElementById('c').appendChild(container);
17+
18+
// GDPR and consent handling
19+
const {
20+
initialConsentMetadata,
21+
initialConsentValue,
22+
noContentAvailable,
23+
renderStart,
24+
} = global.context;
25+
26+
const gdprApplies = initialConsentMetadata?.gdprApplies;
27+
const gdprConsent =
28+
initialConsentMetadata?.consentStringType === CONSENT_STRING_TYPE.TCF_V2
29+
? initialConsentValue
30+
: '';
31+
32+
global.impactifyTag = global.impactifyTag || [];
33+
global.impactifyTag.push({
34+
appId: data['appId'],
35+
format: data['format'],
36+
style: data['style'],
37+
'gdpr_consent': gdprConsent,
38+
gdpr: gdprApplies,
39+
slotId,
40+
isAmp: true,
41+
codeName: `${data['width']}x${data['height']}`,
42+
onAd: () => renderStart(),
43+
onNoAd: () => noContentAvailable(),
44+
});
45+
46+
loadScript(global, 'https://ad.impactify.io/static/ad/tag.js');
47+
}

ads/vendors/impactify.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# impactify
2+
3+
## Example
4+
5+
```html
6+
<amp-ad
7+
width="300"
8+
height="250"
9+
type="impactify"
10+
data-app-id="impactify.io"
11+
data-format="screen"
12+
data-style="static">
13+
</amp-ad>
14+
```
15+
16+
## Configuration
17+
18+
For details on the configuration semantics, please contact the ad network or refer to their documentation.
19+
20+
Supported parameters:
21+
22+
- `data-app-id`
23+
- `data-format`
24+
- `data-style`
25+
26+
## Consent
27+
28+
When used with [`amp-consent`](https://amp.dev/documentation/components/amp-consent/),
29+
Impactify will receive the user's consent state and TCF v2 consent string (when
30+
available).

examples/amp-ad/ads.amp.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@
289289
<option>imedia</option>
290290
<option>imobile</option>
291291
<option>imonomy</option>
292+
<option>impactify</option>
292293
<option>incrementx</option>
293294
<option>industrybrains</option>
294295
<option>inmobi</option>
@@ -1219,6 +1220,10 @@ <h2>Imedia</h2>
12191220
data-positions='[{"id":"p1", "zoneId":"seznam.novinky.ikona2"}, {"id":"p2", "zoneId":"seznam.novinky.ikona"}]'>
12201221
</amp-ad>
12211222

1223+
<h2>Impactify</h2>
1224+
<amp-ad width="300" height="250" type="impactify" data-app-id="impactify.io" data-format="screen" data-style="static">
1225+
</amp-ad>
1226+
12221227
<h2>IncrementX</h2>
12231228
<amp-ad width="300" height="250" type="incrementx" data-vzid="PNXW125273VB49B96">
12241229
</amp-ad>

extensions/amp-ad/amp-ad.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
368368
- [I-Mobile](../../ads/vendors/imobile.md)
369369
- [Imonomy](../../ads/vendors/imonomy.md)
370370
- [Imedia](../../ads/vendors/imedia.md)
371+
[Impactify](../../ads/vendors/impactify.md)
371372
- [Improve Digital](../../ads/vendors/improvedigital.md)
372373
- [IncrementX](../../ads/vendors/incrementx.md)
373374
- [Insticator](../../ads/vendors/insticator.md)

0 commit comments

Comments
 (0)