Adform supports and serves MRAID banners. You can use different MRAID banner formats and components to build in-app banners that meet your needs and use the creative assets you have.
Before building an MRAID banner, review the specifications listed in the Build MRAID Banners article.
Standard MRAID banners can have text, images, or any type of rich media.
-
In Adform Studio, open the Standard banner template.
-
Click in the left side panel.
-
Review the banner template's asset files.
With an MRAID Click-to-Expand banner a viewer clicks it to reveal new content: from a collapsed state to an expanded one. You can use most types of rich media for this type of banner.
A Click-to-Expand banner changes between its collapsed and expanded states with mraid.resize()
and mraid.close()
.
You can change the width and height values in the component to define the expanded dimensions:
mraid.setResizeProperties({ "width": 320, "height": 320, "offsetY": 0, "offsetX": 0, "allowOffscreen": false });
To track banner states, add the EventListener
code:
mraid.addEventListener('stateChange',handleStateChangeEvent);
You can track banner states with:
function handleStateChangeEvent(state) { switch (state) { case 'default': collapsed.style.display = 'block'; expanded.style.display = 'none'; break; case 'resized': expanded.style.display = 'block'; collapsed.style.display = 'none'; break; } }
-
In Adform Studio, open the Click-to-Expand banner template.
-
Click , in the left side panel.
-
Review the banner template's asset files.
MRAID Click-to-Full Screen banners expand to the available screen size. MRAID Click-to-Full screen banner supports most types of rich media.
A Click-to-Full Screen banner changes between collapsed and full screen states with mraid.expand()
and mraid.close()
events.
Track the banner states with:
mraid.addEventListener('stateChange',handleStateChangeEvent);
You can also define scenes, animations, and other details:
function handleStateChangeEvent(state) { switch (state) { case 'default': collapsed.style.display = 'block'; expanded.style.display = 'none'; break; case 'expanded': expanded.style.display = 'block'; collapsed.style.display = 'none'; break; } }
The app provides the banner with a default close button. To include a custom close button, include the following code:
mraid.useCustomClose(true);
To see a full code example on Adform Studio:
-
Open the Click-to-Full Screen banner template.
-
Click in the left side panel.
-
Review banner assets.
MRAID Interstitial banners use all the allocated screen space to serve a full-screen ad.
The app provides the banner with a default close button. To include a custom close button, include the following code:
mraid.useCustomClose(true);
To see a full code example on Adform Studio:
-
Open the Interstitial banner template.
-
Click in the left side panel.
-
Review banner assets.
You add a component to a banner to enhance visitors' engagement and create a richer experience.
With 3D Cube banners, the visitor can reveal additional content in a 3D effect.
Note
Add assets to the 3D cube through Adform FLOW. For a detailed procedure, see Manage Assets.
Add the following code and define values to your banner to have the 3D cube effect:
new Adform.Cube({ vertical: false, autoRotate: 3000, swipeEventStep: 60, customNavigationIcon: false, swipeFinger: "assets/finger.png", preventPageScrolling: false, assets: [ "assets/wall1.png", "assets/wall2.png", "assets/wall3.png", "assets/wall4.png" ] });
Property |
Description |
---|---|
|
The direction of the animation Enter "True" to set a vertical direction, or "False" to set a horizontal direction. |
|
The automatic slide transition time Enter "False" to disable the rotation. |
|
The number of frames moved with one swipe |
|
Enable or disable a custom navigation icon (for example, arrows) |
|
The custom swipe finger image |
|
With "True", visitors can't scroll the page by swiping the ad. |
|
Alternate source for cube wall assets If there are no additional assets, wall assets come from provided sources or folders. |
To see a full code example on Adform Studio:
-
Open the 3D Cube banner template.
-
Click in the left side panel.
-
Review banner assets.
With a 3D cube store locator, you can add a map with a store location to one of the cube's walls. The viewer can swipe or click the 3D cube to reveal the store's map.
Important
The store locator component is based on a third-party library (for example, the Google Map API) that Adform doesn't maintain. This example only shows how to include custom HTML as an iframe on a cube wall.
To add a store locator to one of the walls on your 3D cube, in the assets array, add custom HTML:
new Adform.Cube({ vertical: false, autoRotate: 3000, swipeEventStep: 60, customNavigationIcon: "assets/arrow.png", swipeFinger: "assets/finger.png", preventPageScrolling: false, assets: [ "assets/wall1.png", { type: "html", src: "assets/store-locator.html", scrollableElement: "overlay", navigation: true }, "assets/wall3.png", "assets/wall4.png" ] });
To see a full code example on Adform Studio:
-
Open the store locator template.
-
Click in the left side panel.
-
Review banner assets.
With a slice box, you can split the different sides of a banner into customizable rows. Each row reacts independently when the animation starts and creates a visually appealing transition.
To add a slice box to your 3D cube banner, insert the following code and define the values.
var slicedUnit = new SlicedUnit({ width: 300, height: 250, minScale: 0.95, sliceCount: 10, sliceSideCount: 4, sliceRotationDuration: 0.6, sliceRotationDelay: 0.1, shadow: '#006496', autoRotationDelay: 3, autoRotationTimeout: 25, useVerticalSlices: false, useVerticalRotation: false, useSinglePerspective: true, useOffsetCompensation: false, content: [ {src: 'assets/Panel_1.png', onClick: Adform.getClickURL('clickTAG1')}, {src: 'assets/Panel_2.png', onClick: Adform.getClickURL('clickTAG2')}, {src: 'assets/Panel_3.png', onClick: Adform.getClickURL('clickTAG3')}, {src: 'assets/Panel_4.png', onClick: Adform.getClickURL('clickTAG4')}, {src: 'assets/Panel_5.png', onClick: Adform.getClickURL('clickTAG5')} ], className: 'slicedUnit' });
Property |
Value |
---|---|
|
The slice box width |
|
The slice box height |
|
The scale during animation (1 = 100%) |
|
The number of sliced rows |
|
The number of sides |
|
The duration of individual rotations in seconds |
|
The color of the shadow |
|
The delay between auto rotations |
|
The duration of auto-rotation in seconds |
|
The toggle between sliced rows and columns |
|
The toggle between vertical and horizontal animation |
|
The assets and click tags for individual sides |
To see a full code example on Adform Studio:
-
Open the slice box template.
-
Click in the left side panel.
-
Review banner assets.
Outstream is a video ad that starts playing automatically (without any visitor interaction) once the banner loads completely or when it's more than 50% visible. By default, the video sound is muted, but if a viewer clicks the video, the video expands to full screen mode with the sound enabled. The viewer can exit full screen mode by clicking a close button, which appears in the expanded state.
To see a full code example on Adform Studio:
-
Open the outstream video template.
-
Click in the left side panel.
-
Review banner assets.
With dynamic content, you can have the ad content change without needing to create a new banner. Every time a visitor refreshes the web page, the server loads randomly predetermined content in the same ad space.
Insert the following script in the <head>
element of the container:
<script src="http://s1.adform.net/banners/scripts/mobile/dco.js"></script>
Use the following script to create dynamic content:
<script type="adform/template" data-client="4790" data-template="11780" data-messages="82993283"> {{#messages}} <div > <div id="text1" class="text">{{text1}}</div> <div id="text2" class="text">{{text2}}</div> <div id="text3" class="text">{{text3}}</div> </div> {{/messages}} </script>
Keep in mind that:
-
When an advertiser's data is imported to Adform, the XML file has the following structure:
http://s1.adform.net/Banners/Elements/Templates/{data-client}/{data-template}.xml
. -
Once you upload the banner to Adform, a different template or ad message can be assigned on the platform.
-
For data synchronization and transformation, contact Adform Rich Media Support (technical@adform.com)
To load more ad messages, manipulate text data, or call a function after AdMessage loads, include the following code:
Adform.DCO.loadMessages(1, function(data, total) {//total returns how many AdMessages there are in total data.messages[0]['text3'] = '!'; //text var manipulation return function () { //action when admessage is loaded e.g. start animation } });
To see a full code example on Adform Studio:
-
Open the dynamic content banner template.
-
Click in the left side panel.
-
Review banner assets.
You can use Adform's product recommendation solution (fee-based dynamic content optimization, DCO) to show several products at once in a single banner. The visitors first see the products that they were most interested in.
Insert the following script in the <head>
element of the container:
<script src="http://s1.adform.net/banners/scripts/mobile/dco.js"></script>
Use the following script to create dynamic content:
<script type="adform/template" data-client="4790" data-template="4944" data-messages="" data-engine="2"> {{#messages}} <div class="product"> <div class="product_name">{{product_name}}</div> <div class="product_price">from <span>{{product_price}}</span></div> <img class="product_image" src="{{product_image}}"> <a onclick="mraid.open('{{$link}}');" class="cta">Find out more</a> </div> {{/messages}} </script>
Keep in mind, that:
-
When imported to Adform, the XML file takes the following structure:
http://s1.adform.net/Banners/Elements/Templates/{data-client}/{data-template}.xml
-
It's not necessary to provide a value in the data-messages attribute because the banner loads several products.
-
You must use
{{$link}}
to properly track clicks of individual products. You can load more products by modifying theAdform.DCO.loadMessages(2)
part. -
For data synchronization and transformation, contact Adform Technical Support.
to see a full code example on Adform Studio:
-
Open the product recommendation banner template.
-
Click in the left side panel.
-
Review banner assets.
With the scratch effect, visitors 'scratch' the predefined area and reveal the ad message.
To add the scratch effect to a banner, insert the following code snippet and define the values:
Adform.Scratch.init({ width: 0, height: 0, image: "assets/image.jpg", percentage: 75, radius: 30, delay: 0, zIndex: 0, intensity: 0.6, fadeDuration: 500 });
Property |
Description |
---|---|
|
The number 0 sets the relevant dimension to 100%. To make the size static, set these values in pixels. |
|
The top image to be scratched. This value is overridden, if |
|
The amount of the area that needs to be scratched off to reveal the banner |
|
The scratch radius in pixels |
|
Time in milliseconds to auto-reveal the banner after the banner appears in a visitor's view Set to 0 to disable auto-revealing. |
|
The z-index of the canvas element that's scratched Use 0 to disable the z-index. |
|
The scratching intensity Set to a number from 0 to 1. The default value is 0.6. |
|
The duration of the fading animation when the canvas is being removed |
To see a full code example on Adform Studio:
-
Open the scratch banner template.
-
Click in the left side panel.
-
Review banner assets.
A slider banner displays several images (slides) that transition smoothly from one to another. The images change after a defined period of time or after a specified viewer interaction.
To have your banner display slides, use this code snippet and define the values:
new Adform.Slider({ vertical: true, pagination: true, autoSlideTime: 3000, slideFinger: "assets/finger.png", preventPageSwiping: false, assets: [ "assets/slide1.png", "assets/slide2.png", "assets/slide3.png", "assets/slide4.png" ] });
Property |
Description |
---|---|
|
The direction of the animation Enter "True" or "False" depending on the direction you want to set. |
|
The pagination dots that appear at the bottom of the banner |
|
The transition time to show the next slide To disable, set to "False". |
|
A link to the slide icon |
|
This setting disables the vertical swipe event on the page |
|
The links to images |
To see the full code example on Adform Studio:
-
Open the slider banner template.
-
Click in the left side panel.
-
Review banner assets.
By obtaining a visitor's geolocation, you can show custom functions (such as locating the nearest store or displaying different text or images).
Note
Have a fallback logic in the banner for cases when the method returns a null value because the geolocation isn't always available.
The geolocation information includes approximate latitude and longitude. You can access this information by entering the following line of code:
var location = Adform.getLocation() // Returns {lat: Number, lng: Number} object
Note
The geolocation is available only in the final created tag. Adform Studio and the banner preview on Adform FLOW return a null value.
Markers can be loaded directly through an object or through a JSON file:
var markers; var req = new XMLHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4 && req.status == 200) { markers = JSON.parse(req.responseText); } }; req.open('GET', 'locations.json', true); req.send();
JSON file, or a simple object should contain latitude, longitude, and a title for each marker:
{ "title": "Adform Vilnius", "latitude": 54.694997, "longitude": 25.298734 }, { "title": "Adform Copenhagen", "latitude": 55.672294, "longitude": 12.588974 }
Note
Create a fallback logic in the banner for cases when a null value is returned because the geolocation may not always be available.
Polite loading delays the loading of creative assets (such as images) until the web page has finished loading.
To implement the polite load feature on an MRAID banner, you must insert the code manually:
-
Wrap the video element (or an image) in a
<div>
tag, that defines polite loading:<div id="politeImg" style="opacity: 1; position: absolute; width:100%; height:100%; background-image: url('assets/politeImage.png'); background-size: contain;"></div> <!-- initial div with polite image set as background - opacity:1; --> <div id="content" style="opacity: 0;"> <!-- hiding heavy content - opacity:0; --> <video id="video" poster="assets/poster.png" controls> <source src="some_video_from_asset.mp4" type="video/mp4"> </video> </div>
-
Add an
EventListener
:<script> document.addEventListener("DOMContentLoaded", function() { //waiting for all banner content to be loaded //polite start var politeImg = document.getElementById("politeImg"); //assigning polite div var content = document.getElementById("content"); //assigning main div window.setTimeout(function(){ //setting fake time out to display politeness politeImg.style.opacity = 0; //hiding polite div content.style.opacity = 1; //displaying main div }, 2000); //fake timeout - 2000msec //polite end //...user code... }); </script>