Promotions Banner
Display messages inside your apps in an easy and straightfoward way
Our Promotions Banner widget will allow you to display a message when your website gets displayed inside the apps, so you can provide exclusive app offers to your users.
Here's an example:
ML Promotions Banner features:
Promotions Banner can be used importing the JS code via CDN or as a module using NPM
<script type="module" src="https://cdn.jsdelivr.net/npm/@mobiloud/ml-promotions-banner@latest/dist/ml-promotions-banner.min.js"></script>
<script>
function addPromotionsBanner() {
new PromotionsBanner().init();
}
window.addEventListener('load', addPromotionsBanner);
</script>
@mobiloud/ml-promotions-banner
npm i @mobiloud/ml-promotions-banner
const options = {
fontFamily: `"Source Sans Pro", "Arial", sans-serif`, // Font family for banner texts, defaults to system safe fonts
textColor: '#222', // Banner texts color (any color property value),
textHeading: 'Get a discount on your first purchase', // Heading Text
textDescription: 'Use coupon <strong onclick=navigator.clipboard.writeText(this.textContent)>10OFF</strong>', // Description text
bannerColor: 'white', // Banner BG color
link: '#', // Link for button
position: 'top', // Position of the banner, default 'top'. 'top' | 'bottom'
animation: 'fadeIn', // Banner animation, default 'fadeIn'. 'fadeIn' | 'scaleUp' | 'slideBottom' | 'slideTop' | 'slideLeft' | 'slideRight' | null,
display: 'onLoad', // Display options, default 'onLoad'. 'onLoad' | 'onScrollDown' | 'onScrollUp'
radius: '0', // Banner radius with units
delay: 0, // defines how much time to wait until the element shows up in ms
shadow: true, // If true applies soft shadow, true | false
useSession: false,
zindex: 9999999
}
const promotionsBanner = new PromotionsBanner(options);
deviceData.os // returns current os "android" | "ios" | "windows" | "desktop"
deviceData.isCanvas // returns true or false
deviceData.isMobile // returns true or false
This are useful ways to implement the widget
const options = {
fontFamily: `"Source Sans Pro", "Arial", sans-serif`, // Font family for banner texts, defaults to system safe fonts
textColor: '#222', // Banner texts color (any color property value),
textHeading: 'Get a discount on your first purchase', // Heading Text
textDescription: 'Use coupon <strong onclick=navigator.clipboard.writeText(this.textContent)>10OFF</strong>', // Description text
bannerColor: 'white', // Banner BG color
link: '#', // Link for button
position: 'top', // Position of the banner, default 'top'. 'top' | 'bottom'
animation: 'fadeIn', // Banner animation, default 'fadeIn'. 'fadeIn' | 'scaleUp' | 'slideBottom' | 'slideTop' | 'slideLeft' | 'slideRight' | null,
display: 'onLoad', // Display options, default 'onLoad'. 'onLoad' | 'onScrollDown' | 'onScrollUp'
radius: '0', // Banner radius with units
delay: 0, // defines how much time to wait until the element shows up in ms
shadow: true, // If true applies soft shadow, true | false
useSession: false,
zindex: 9999999
}
// Insert banner only in our Canvas platform
if(deviceData.isCanvas) {
const promotionsBanner = new PromotionsBanner(options);
}
// Apply specific configs based on OS
if(deviceData.os === "android" || deviceData.os === "windows") {
const promotionsBanner = new PromotionsBanner({link: 'https://linkOne.com'});
}
if(deviceData.os === "desktop" || deviceData.os === "ios") {
const promotionsBanner = new PromotionsBanner({link: 'https://linkTwo.com'});
}
// Insert banner only in Mobile userAgent
if(deviceData.isMobile) {
const promotionsBanner = new PromotionsBanner(options);
}
// Set banner text with an onclick function in it
const options = {
textDescription: `Please use code <strong onclick="copyBannerText(this, '10OFF')">10OFF</strong> for 10% off in your next order!`
}
// Create the copyBannerText function that is linked to the description text, it copies the text, displays a "Copied!" message in that place and then shows the passed text again
function copyBannerText(e, text){
navigator.clipboard.writeText(text);
e.textContent = "Copied!"
setTimeout( function() {
e.textContent = text
}, 3000);
}
function addPromotionsBanner() {
// Here we can use the deviceData method to display the banner only on desired devices
new PromotionsBanner(options).init();
}
window.addEventListener('load', addPromotionsBanner);