API

The API places itself in the namespace window.mmAPI and contains just one method, placeAd.

placeAd(options, callback):

  • options: A javascript object. This object will look different depending on whether the requested ad is inline or an interstitial.
  • callback (optional): A function to be called when the ad has been placed. The callback should take one boolean parameter. This parameter will be true if the ad request was successful, and false otherwise.

A sample callback function:

function callBack(adFilled) {
    //adFilled will be true if the ad fills, else it will be false
    console.log("was the ad filled: " + adFilled);
    if (adFilled) {
        ...
    } else {
        ...
    }
};

Inline Options

Name Type Required Description
containerElementId string yes The id of the element that the ad will be placed inside of.
apid string yes Your assigned apid.
placementType string yes Ad type. Set to “inline” for banners and rectangles.
width number yes The width of the placement.
height number yes The height of the placement.
allowLocation boolean no If true, the Javascript Ad Tag will attempt to pass lat and long parameters on the ad call. Default is false.
passbackURL string no If the ad is a no fill and this parameter exists, an iframe will be created with a src of this url. Note: Do not use both passbackURL and passbackJS. Please pick one if you want to use a passback.
passbackJS string no If the ad is a no fill and this parameter exists, a script will be created with a src of this javascript file. Note: Do not use both passbackURL and passbackJS. Please pick one if you want to use a passback.
passbackJSVars object no When using the passbackJS parameter, passbackJSVars can be used to define variable names/values that should be available on the window object for the passback script to use.
metadata object no See metadata section
onExpand function no If set, this function will be called when an ad is expanded.
onClose function no If set, this function will be called when an expanded ad is closed back down to banner size.
onClick function no If set, this function will be called the first time an ad is clicked.

Interstitial Options

Name Type Required Description
containerElementId string yes The id of the element that the ad will be placed inside of.
apid string yes Your assigned apid.
placementType string yes Ad type. Set to “interstitial” for interstitials.
allowLocation boolean no If true, the Javascript Ad Tag will attempt to pass lat and long parameters on the ad call. Default is false.
passbackURL string no If the ad is a no fill and this parameter exists, an iframe will be created with a src of this url. Note: Do not use both passbackURL and passbackJS. Please pick one if you want to use a passback.
passbackJS string no If the ad is a no fill and this parameter exists, a script will be created with a src of this javascript file. Note: Do not use both passbackURL and passbackJS. Please pick one if you want to use a passback.
passbackJSVars object no When using the passbackJS parameter, passbackJSVars can be used to define variable names/values that should be available on the window object for the passback script to use.
metadata object no See metadata section
onExpand function no If set, this function will be called when an ad is displayed.
onClose function no If set, this function will be called when an ad is hidden.
onClick function no If set, this function will be called the first time an ad is clicked.

Inline Example

Remember to replace <YOUR_APID> with your actual APID value.

<script>
    window.mmAPI.placeAd({
        containerElementId: "adContainer",
        apid: "<YOUR_APID>",
        placementType: "inline",
        width: 728,
        height: 90,
        allowLocation: true,
        passbackURL: "http://www.test.com/passBack"
    }, function(adFilled) {
        //adFilled will be true if the ad fills, else it will be false
        console.log("was the ad filled: " + adFilled);
        if (adFilled) {
        }
    });
</script>

Interstitial Example

Remember to replace <YOUR_APID> with your actual APID value.

<script>
    window.mmAPI.placeAd({
        containerElementId: "adContainer",
        apid: "<YOUR_APID>",
        placementType: "interstitial",
        allowLocation: true,
        passbackJS: "http://www.test.com/passBack.js"
    }, function(adFilled) {
        //adFilled will be true if the ad fills, else it will be false
        console.log("was the ad filled: " + adFilled);
        if (adFilled) {
        }
    });
</script>

Metadata

In order to enable us to serve more relevant ads to your users, you can provide us with metadata about a user on an ad request. The table below shows the keys the metadata object can take and acceptable values:

Key Name Acceptable Values
age An integer between 0 and 115
gender “male”, “female”, “other”, or “unknown”
ethnicity “middleeastern”, “asian”, “black”, “indian”, “nativeamerican”, “pacificislander”, “white”, “other”, or “unknown”
zip A 5 digit integer
education “none”, “highschool”, “incollege”, “somecollege”, “associates”, “bachelors”, “masters”, “doctorate”, “other”, or “unknown”
marital “single”, “relationship”, “married”, “divorced”, “engaged”, “other”, or “unknown”
keywords A string with comma separated words

Metadata example

Remember to replace <YOUR_APID> with your actual APID value.

<script>
    window.mmAPI.placeAd({
        containerElementId: "adContainer",
        apid: "<YOUR_APID>",
        placementType: "interstitial",
        metadata: {
            age: 34,
            gender: "female",
            zip: 21224,
            ethnicity: "nativeamerican",
            education: "masters",
            marital: "married",
            keywords: "these,are,my,keywords"
        }
    });
</script>