For Google AMP advertising, if the tenant is using Twister, all the configuration is done automatically. If not, all the configuration is done in definition.json, inside userInterface.features.

In addition, depending on the business model to configure, Marfeel must define the next data.

AMP Advertising by Model

Enterprise

This is the default option and will use Marfeel's tags to make ad impressions.

One ad per page

For tenants using Twister

Marfeel must activate Twister in AMP by using the following flag inside definition.json:

"TwisterJavaEnabled": true,
CODE

After adding this flag it should be tested.

If the ads for AMP are not properly configured, there will be an error in the console like the following example for not returning the loadMad:

No mad is loaded - vp: 1 - madId: 0
CODE

Any time a change is made in ads file, be sure to test it in touch and AMP.

Check if all the required ad servers are implemented in Twister for AMP. If not, the Marfeel K team should be asked to mock it. 

For tenants not using Twister

Marfeel must define the logic on the tags behind the custom main JavaScript, when the ad type is 'sRoba' for DFP.

The following data is available to be defined:

  • advertisement.adservers: contains all the adservers and configuration parameters to be used in all the placements.
  • advertisement.placements.sRoba: adserver of the sRoba impressions
"advertisement": {
	"adservers": {
      "doubleClick": {
        "slotName" : "slotName1", --> this is the default slotname for all the impressions
        "width": "ad width",
        "height": "ad height",
        "virtualPages" : {
          "page1": {
            "slotName" : "slotNameForPage1" ---> slotname overwriten for page1
          },
          "pageN": {
            "slotName" : "slotNameForPageN" ---> slotname overwriten for pageN
          }
        }
      }
    },

    "placements": {                         ---> and then we define the placement for sRoba to use the doubleClick adserver defined
      "sRoba": "doubleClick"
    }
}
CODE

As the One ad Per Page model needs that page 2 be a Marfeel impression, the page2 slot shouldn't be defined. Only for special cases can the slotName for page2 be defined.

If the slotName needs to be calculated, for example with the section name of the article, this can be modified using a JSP overwritten in themes/amp/mads/customAdsConfiguration.jsp. There, Marfeel can change any adConfiguration value.

Full Example from mejorconsalud.com:

a) Code from PublisherAdServer.js to translate into definition.json

There is nothing to do here; it's only the example code that will be translated into the definition.json in step b)

 var slotNamePositionDetails = {
            1: "box_top",
            2: "box_middle_up",
            3: "box_middle_down",
            4: "box_lower",
            default: "box_other"
        },
        MADTYPE_TO_SIZE = {
            skyscraper: [160, 600],
            s320: [300, 50],
            sky300: [300, 600],
            sRoba: [[300, 250], [300, 600]]
        },
        PROMOTED_ARTICLES_URLS = [
            "domain.com/article-title",
            "domain.com/article-title"
        ];


    function getSlotName(slotName, madType, layout, virtualPage, level) {
        var slotNameId = "/7120678/" + slotName + "_sizes_mobile_generic_";

        if(madType === "sRoba" || madType === "sky300") {
            return slotNameId + slotNamePosition(layout, level, parseInt(virtualPage));
        }

        return "/7120678/" + slotName + "_sizes_marfeel";
    }

    function translatorClosure(sectionId, madType, layout, virtualPage, level) {
        //Remove advertisement for a concrete article of MejorConSalud
        if(isPromotedArticle()){
            if(madType === "bottomDetailsAd") {
                return {
                    name: "/7120678/MCS_1x1_desktop_contextual_home",
                    size: [1, 1]
                };
            }
            return null;
        }
        return {
            name : getSlotName(this.slotName, madType, layout, virtualPage, level),
            size : MADTYPE_TO_SIZE[madType],
            targeting : {
                red: ["false"]
            }
        };
    }
CODE

 

b) Code to put into definition.json, extracted from the previous JS

"advertisement": {
    "adservers": {
      "doubleClick": {
        "slotName" : "/7120678/MCS_sizes_mobile_generic_box_other",
        "customTargeting": "\"red\": \"false\"",
        "width": "300",
        "height": "250",
        "virtualPages" : {
          "page1": {
            "slotName" : "/7120678/MCS_sizes_mobile_generic_box_top"
          },
          "page3": {
            "slotName" : "/7120678/MCS_sizes_mobile_generic_box_middle_down"
          },
          "page4": {
            "slotName" : "/7120678/MCS_sizes_mobile_generic_box_lower"
          }
        }
      }
    },

    "placements": {
      "sRoba": "doubleClick"
    }
  }
CODE

 

c) customAdConfiguration.jsp

In the article there are some promoted articles with special requirements - AMP ad impressions cannot be made on them.

To implement this an overwrite can be performed /themes/amp/mads/customAdConfiguration.jsp to check the URL for the custom articles and then set the adConfiguration data to null:

<%@page pageEncoding="UTF-8" %>

<c:if test="${fn:containsIgnoreCase(item.uri, 'domain.com/article-title') ||
              fn:containsIgnoreCase(item.uri, 'domain.com/article-title')}">
    <c:set var="adConfiguration" value="${null}" scope="request"/>
</c:if>
CODE

 

Another interesting example is the diariocorreo.pe where a {sectionId} is defined in slotNames to be replaced in customAdConfiguration.jsp:

slotName: "/3014206/diariocorreo_movil_300x250_{sectionId}_1"

customAdConfiguration.jsp:
    <c:when test="${fn:containsIgnoreCase(item.uri, 'diariocorreo.pe/politica/')}">
        <c:set var="sectionId" value="politica" scope="request"/>
    </c:when>

	<c:set target="${adConfiguration}" property="slotName" value="${fn:replace(adConfiguration.slotName,'{sectionId}', sectionId)}" />
CODE

AMP native ads

For tenants using Twister

If the tenant is using the Twister configuration, by default Marfeel doesn't need to make any change on the AMP configuration.

If the native ad server is Outbrain then it needs to be configured according to the Example configuring Outbrain section in this article. 

For tenants not using Twister

The next ad networks to be supported: Teads, Ligatus, Taboola, and revContent.

  • advertisement.adservers: contains all the adservers and configuration parameters to be used in all the placements.
  • advertisement.placements.nativeAdvInDetails: array containing the sequence of placements indicating the adserver to use in that placement.
"advertisement": {
	"adservers": {
		"adserver1": {
			"parameter1": "value1"
		},
		"adserver2": {
		"parameter1": "value1"
		}
	},
	
	"placements": {
		"nativeAdvInDetails": ["adserver1","adserver2"] --> Can be an array or a single adserver
	}
}
CODE

The example will make an impression of adserver1 and just below an impression of adserver2.

Adservers and data to be defined:

  • teads: parameters = { pid }
  • teadsDFP: { pageId, dataSlot }
  • ligatus: { placementId }
  • taboola: { publisher, mode, placement, targetType }
  • revContent: { id }
  • outbrain: { widgetIds, tenantUrl }

     

Example configuring revContent

"advertisement": {
  "adservers": {
    "revContent": {
      "id": "3287"
    }
  },

  "placements": {
    "nativeAdvInDetails": ["revContent"]
  }
}
CODE

 

Example configuring Ligatus:

"advertisement": {
    "adservers": {
        "ligatus": {
            "placementId": "80087"
        }
    },

    "placements": {
        "nativeAdvInDetails": "ligatus"
    }
}
CODE

 

Example configuring Taboola

"advertisement": {
  "adservers": {
    "taboola": {
      "publisher":"brasil247",
      "mode": "thumbnails-a",
      "placement": "Below Article Thumbnails",
      "targetType": "mix"
    }
  },

  "placements": {
    "nativeAdvInDetails": "taboola"
  }
}
CODE

Example configuring Outbrain

"advertisement": {
"adservers": {
"outbrain":
{ "widgetIds": "MB_1", "tenantUrl": "www.domain.com" }
},
"placements":
{ "nativeAdvInDetails": "outbrain" }
}
CODE