Skip to content

Commit

Permalink
AMP implementation of Media.net header bidder
Browse files Browse the repository at this point in the history
Update ads.amp.html

Modify A4A AMP Creative to use ampRuntimeUtf16CharOffsets from validation rewrite (ampproject#5982)

* Update amp-ad-network-doubleclick-impl.md

* Reverting doc changes

The previous change was made in error (wrong branch).

* Initial changes, need to update tests

* Start fixing tests

* Fix unit test coverage

* revert a4a examples

Introduce amp-auto-id attribute to AMP element. (ampproject#5973)

* Introduce amp-auto-id attribute to AMP element.

* Fix tests

* Address comments

* Address comments

* revert

amp-live-list.md polling clarification (ampproject#5991)

Only report 1% of errors if a page has non-AMP JS (ampproject#5994)

Fixes ampproject#5732

Allow for hosted testing to override where third party frame is retrieved from (ampproject#5890)

* Allow for hosted testing to override where third party frame is retrieved from

* test my own site

* fix ava tests

Remove unsupported query selector feature (ampproject#5999)

Workaround for misbehaving webview viewer (ampproject#6001)

A webview viewer from Google is seing origins of the form `www.google.com`.

For the time being we accept these as they trigger errors in our error reporting that aren't useful. As this form of origins can only occur with webviews that have full control over the page via JS injection anyway, this change should make no difference for normal web usage.

A4A integration tests (ampproject#5812)

* First draft of full integration tests for A4A.

* First draft of full integration tests for A4A.

* Got tests of exception conditions working.  Refactored some common stuff to utils.js.

* Refactored XDom and friendly iframe tests to helpers.

* Added tests.

* Resolved merge conflicts.

* Centralized visibility check and updated visibility test.

* Moved all A4A tests to using central visibility test.

* Lint fixes.

* Changed custom expectations to local functions.

* Replaced stringToArrayBuffer with utf8Encode.

* Fixed visibility assertion.

* Lint fixes.

* Added a comment (partly in order to get Travis to re-run).

* Changes in response to reviews.

* Rebased and fixed small rebase error.

Fixes an issue where ads are not correctly centered on certain platforms. (ampproject#6003)

* Centralized creative centering in doubleclick.js, and changed css 'transform' to a more commonly supported property.

* Added check for existence and changed to plain old 'transform'.

* Now asserting the existence of the container.

amp-sticky-ad close button new style (ampproject#5979)

* unit style

* fix css

* fix test

* rebase

* fix z-index

Other JS errors: Use startsWith (ampproject#6006)

Fixes ampproject#5994 (comment).

Fix log calls without TAGNAME (ampproject#6005)

My presubmit was a bit too lenient, and too strict at the same time.

refactor amp-ad.css (ampproject#5992)

Combine amp-analytics var docs with var substitutions doc re: ampproject#1302 (ampproject#5576)

* Combine amp-analytics var docs with var substitutions doc re: ampproject#1302

* Updated non-supported vars + format changes for amp-analytics vars

* Updates per Avi's feedback

* Updated descriptions for amp-carousel vars

add version parameter to AMP.extension signature (ampproject#5989)

* add version parameter to AMP.extension signature

* apply recommendations

* remove TODO

Improve error reporting (ampproject#6019)

- Include the current `location.hash`. We are missing it, because it is not included in the referrer.
- Include previously recorded errors, so it is easier to identify follow on errors.
- Kill the 2000 char limit as it isn't important for AMP's target browsers.

Include the originalHash (ampproject#6020)

We remove the hash in embedding mode, so the original code doesn't actually work.

Fix error: "Can't find variable: TextDecoder"  (ampproject#6011)

* Update amp-ad-network-doubleclick-impl.md

* Reverting doc changes

The previous change was made in error (wrong branch).

* Initial changes, need to update tests

* Start fixing tests

* Fix unit test coverage

* revert a4a examples

* Include self (window) when verifying TextDecoder/TextEncoder existence

* fix upstream conflict

* PR feedback

* PR feedback
  • Loading branch information
monish-chhadwa authored and ruturajv-media-net committed Nov 4, 2016
1 parent fe4686f commit 0e08fb9
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 1 deletion.
2 changes: 2 additions & 0 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import {loka} from '../ads/loka';
import {mads} from '../ads/mads';
import {mantisDisplay, mantisRecommend} from '../ads/mantis';
import {mediaimpact} from '../ads/mediaimpact';
import {medianet} from '../ads/medianet';
import {mediavine} from '../ads/mediavine';
import {meg} from '../ads/meg';
import {microad} from '../ads/microad';
Expand Down Expand Up @@ -189,6 +190,7 @@ register('mads', mads);
register('mantis-display', mantisDisplay);
register('mantis-recommend', mantisRecommend);
register('mediaimpact', mediaimpact);
register('medianet', medianet);
register('mediavine', mediavine);
register('meg', meg);
register('microad', microad);
Expand Down
5 changes: 5 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ export const adConfig = {
renderStartImplemented: true,
},

medianet: {
preconnect: 'https://contextual.media.net',
renderStartImplemented: true,
},

mediavine: {
prefetch: 'https://www.googletagservices.com/tag/js/gpt.js',
preconnect: [
Expand Down
129 changes: 129 additions & 0 deletions ads/medianet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {writeScript, validateData, computeInMasterFrame} from '../3p/3p';
import {getSourceUrl} from '../src/url';
import {doubleclick} from '../ads/google/doubleclick';

const mandatoryParams = ['tagtype', 'cid'],
optionalParams = [
'timeout',
'slot', 'targeting', 'categoryExclusions',
'tagForChildDirectedTreatment', 'cookieOptions',
'overrideWidth', 'overrideHeight', 'loadingStrategy',
'consentNotificationId', 'useSameDomainRenderingUntilDeprecated',
'experimentId', 'multiSize', 'multiSizeValidation',
],
dfpParams = [
'slot', 'targeting', 'categoryExclusions',
'tagForChildDirectedTreatment', 'cookieOptions',
'overrideWidth', 'overrideHeight', 'loadingStrategy',
'consentNotificationId', 'useSameDomainRenderingUntilDeprecated',
'experimentId', 'multiSize', 'multiSizeValidation',
],
dfpDefaultTimeout = 1000;

/**
* @param {!Window} global
* @param {!Object} data
*/
export function medianet(global, data) {
validateData(data, mandatoryParams, optionalParams);

const publisherUrl = global.context.canonicalUrl ||
getSourceUrl(global.context.location.href),
referrerUrl = global.context.referrer;

if (data.tagtype === 'headerbidder') { //parameter tagtype is used to identify the product the publisher is using. Going ahead we plan to support more product types.
loadHBTag(global, data, publisherUrl, referrerUrl);
}
}

/**
* @param {!Window} global
* @param {!Object} data
* @param {!string} publisherUrl
* @param {?string} referrerUrl
*/
function loadHBTag(global, data, publisherUrl, referrerUrl) {
function deleteUnexpectedDoubleclickParams() {
const allParams = mandatoryParams.concat(optionalParams);
let currentParam = '';
for (let i = 0; i < allParams.length; i++) {
currentParam = allParams[i];
if (dfpParams.indexOf(currentParam) === -1 && data[currentParam]) {
delete data[currentParam];
}
}
}

let isDoubleClickCalled = false;

function loadDFP() {
if (isDoubleClickCalled) {
return;
}
isDoubleClickCalled = true;

global.advBidxc = global.context.master.advBidxc;
if (global.advBidxc && typeof global.advBidxc.renderAmpAd === 'function') {
global.addEventListener('message', function(event) {
global.advBidxc.renderAmpAd(event, global);
});
}

data.targeting = data.targeting || {};

if (global.advBidxc &&
typeof global.advBidxc.setAmpTargeting === 'function') {
global.advBidxc.setAmpTargeting(global, data);
}
deleteUnexpectedDoubleclickParams();
doubleclick(global, data);
}

function mnetHBHandle() {
global.advBidxc = global.context.master.advBidxc;
if (global.advBidxc &&
typeof global.advBidxc.registerAmpSlot === 'function') {
global.advBidxc.registerAmpSlot({
cb: loadDFP,
data,
winObj: global,
});
}
}

global.setTimeout(function() {
loadDFP();
}, data.timeout || dfpDefaultTimeout);

computeInMasterFrame(global, 'medianet-hb-load', function(done) {
/*eslint "google-camelcase/google-camelcase": 0*/
global.advBidxc_requrl = publisherUrl;
global.advBidxc_refurl = referrerUrl;
global.advBidxc = {};
global.advBidxc.registerAmpSlot = () => {
};
global.advBidxc.setAmpTargeting = () => {
};
global.advBidxc.renderAmpAd = () => {
};
writeScript(global, 'https://contextual.media.net/bidexchange.js?https=1&amp=1&cid=' + encodeURIComponent(data.cid), () => {
done(null);
});
}, mnetHBHandle);
}
72 changes: 72 additions & 0 deletions ads/medianet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!---
Copyright 2016 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Media.net

Media.net adapter supports the integration of its Header Bidding solution with the publisher website that uses DoubleClick for Publishers (DFP) as the Ad Server. The example listed below states the configuration and the implementation related details.


## Example

### Media.net Header Bidder

``` html
<amp-ad width="300" height="250"
type="medianet"
data-tagtype="headerbidder"
data-cid="8CU852274"
data-slot="/45361917/AMP_Header_Bidder"
json='{"targeting":{"mnetAmpTest":"1","pos":"mnetSlot1"}}'>
</amp-ad>

```

## Configuration

### Dimensions

The ad size depends on the ``width`` and ``height`` attributes specified in the ``amp-ad`` tag. The ``amp-ad`` component requires the following mandatory HTML attributes to be added before parsing the Ad.

* ``width``
* ``height``
* ``type = "medianet"``

For further configuration related details, please feel free to reach out to your Media.net contact.

## Supported Parameters

###Media.net Header Bidder

<strong>Mandatory Parameters</strong>

* ``data-tagtype`` - This parameter represents the product the publisher is using; It should be <strong>headerbidder</strong> for our Header Bidding solution.
* ``data-cid`` - Represents the unique customer identifier.
* ``data-slot`` - Ad unit as specified in DFP


<strong>Some of the parameters supported via Json attribute (DFP Parameters)</strong>

* ``targeting``
* ``categoryExclusions``

For an exhaustive list of updated parameters supported by DoubleClick refer to the guide - [here](google/doubleclick.md).


## Support
For further queries, please feel free to reach out to your contact at Media.net.

Otherwise you can write to our support team:
Email: <strong>pubsupport@media.net</strong>
14 changes: 13 additions & 1 deletion examples/ads.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ <h2>Ad networks in <span class="broken">red color</span> have broken examples, p
<a href="#loka">LOKA</a> |
<a href="#mads">MADS</a> |
<a href="#mantis-display">MANTIS</a> |
<a href="#mediavine">Mediavine</a> |
<a href="#mediaimpact">Media Impact</a> |
<a href="#medianet">Media.Net</a> |
<a href="#mediavine">Mediavine</a> |
<a href="#meg">Meg</a> |
<a href="#microad">MicroAd</a> |
<a href="#mixpo">Mixpo</a> |
Expand Down Expand Up @@ -690,6 +691,17 @@ <h2 id="mediaimpact">Media Impact</h2>
<div fallback></div>
</amp-ad>

<h2 id="medianet">Media.Net Header Bidder AdTag</h2>
<amp-ad width="300" height="250"
type="medianet"
data-tagtype="headerbidder"
data-cid="8CU852274"
data-slot="/45361917/AMP_Header_Bidder"
json='{"targeting":{"mnetAmpTest":"1","pos":"mnetSlot1"}}'>
<div placeholder></div>
<div fallback></div>
</amp-ad>

<h2 id="mediavine">Mediavine</h2>
<amp-ad width="300" height="250"
type="mediavine"
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 @@ -123,6 +123,7 @@ resources in AMP. It requires a `type` argument that select what ad network is d
- [MADS](../../ads/mads.md)
- [MANTIS](../../ads/mantis.md)
- [MediaImpact](../../ads/mediaimpact.md)
- [Media.net](../../ads/medianet.md)
- [Mediavine](../../ads/mediavine.md)
- [Meg](../../ads/meg.md)
- [MicroAd](../../ads/microad.md)
Expand Down

0 comments on commit 0e08fb9

Please sign in to comment.