How to make custom native slideshow ads
A slideshow ad combines multiple videos, images, or a combination of both that viewers can scroll through. It's often used to showcase several products at once, or to list a product's features. You can use native templates to create slideshow ad items that are tailored to your needs.
If you'd rather sanitize the template and have only HTML inside it, you should make your slideshow ad using a styled native ad template instead. For more information on the differences between custom native ads and styled native ads, read About native ad templates.
You will learn:
- How to create a template for a custom slideshow ad. You can customize the sample code to fit your needs.
- How to create a custom slideshow ad item once you have a custom slideshow template.
How to create a custom slideshow ad template
This template will require the user to provide the URLs to where the image creatives are hosted as well as the destination URLs for each image when creating the slideshow ad item.
- Click Templates in the left navigation menu. The Templates section will appear.
- Click Native Ad Templates. The Native Ad Templates subsection will appear.
- Click Add Native Ad Template. The New Native Template window will appear.
- Click Custom Rendering/API. The New Native Ad Template page will appear.
- Name the template then add the variables as needed. In our sample code, we used three Image URL variables and three URL variables (you can use either raw or encoded). We called the image URL variables ImageURL, ImageURL2, and ImageURL3, and the URL variables DestinationURL, DestinationURL2, and DestinationURL3.
- Enter the code in the HTML Template (Custom Rendering) field, then click Save Changes.
Here's the code we used in our example:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
.slides-container {
position: relative;
}
.slide-label {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
.slide {
display: none;
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
.slide:first-of-type {
display: block;
}
.slide img {
width: 100%;
}
.dot-container {
width: fit-content;
margin: 1rem auto;
}
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.dot:first-of-type {
background-color: #717171;
}
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -22px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
.slideshow-close-button-container {
position: absolute;
top: 15px;
right: 15px;
cursor: pointer;
}
.slideshow-close-button {
width: 26px;
text-align: center;
display: inline-block;
color: #ffffff;
font-size: 22px;
background: #000000;
border-radius: 26px;
user-select: none;
}
</style>
</head>
<body>
<div class="slideshow-container">
<div class="slides-container">
<div class="slide">
<div class="slide-label">
Advertisement 1
</div>
<a href="[TRACKING_LINK][%DestinationURL%]" target="_blank">
<img src="[%ImageURL%]">
</a>
</div>
<div class="slide">
<div class="slide-label">
Advertisement 2
</div>
<a href="[TRACKING_LINK][%DestinationURL2%]" target="_blank">
<img src="[%ImageURL2%]">
</a>
</div>
<div class="slide">
<div class="slide-label">
Advertisement 3
</div>
<a href="[TRACKING_LINK][%DestinationURL3%]" target="_blank">
<img src="[%ImageURL3%]">
</a>
</div>
<a class="prev" onclick="changeSlide(-1)">
<
</a>
<a class="next" onclick="changeSlide(1)">
>
</a>
<div class="slideshow-close-button-container">
<span class="slideshow-close-button" onclick="closeButton()">×</span>
</div>
</div>
<div class="dot-container">
<div class="dot" onclick="showSlide(0)"></div>
<div class="dot" onclick="showSlide(1)"></div>
<div class="dot" onclick="showSlide(2)"></div>
</div>
</div>
<script>
var slides, dots;
var currentSlideIndex = 0;
function showSlide(slideIndex) {
var prevSlideIndex = currentSlideIndex;
currentSlideIndex = slideIndex;
if (!slides || ! dots) {
slides = document.querySelectorAll(".slide");
dots = document.querySelectorAll( ".dot");
}
if (currentSlideIndex > slides.length - 1) {
currentSlideIndex = 0
}
if (currentSlideIndex < 0) {
currentSlideIndex = slides.length - 1;
}
slides[prevSlideIndex].style.display = "none";
dots[prevSlideIndex].style.backgroundColor = "#bbb";
slides[currentSlideIndex].style.display = "block";
dots[currentSlideIndex].style.backgroundColor = "#717171";
}
function changeSlide(addToIndex) {
showSlide(currentSlideIndex + addToIndex);
}
function closeButton() {
document.querySelector('.slideshow-container').style.display = 'none';
}
</script>
</body>
</html>
You can now use this template to create a custom slideshow ad item.
How to create a custom slideshow ad item
- Go to the section of the relevant zone (Your AdButler > Publishers > Your Publisher > Your Zone) or campaign (Your AdButler > Advertisers > Your Advertiser > Your Campaign).
- Click Add Ad Item in the Ad Items table. The Add Ad Item window will appear.
- Click Native (Custom Rendering/API). The New Ad Item page will appear.
- Set the ad item's size.
If the ad item or its campaign will be assigned to a Standard zone, you must set the ad item's size to Dynamic.
If the ad item or its campaign will be assigned to a Native zone, you must enter the ad item's exact size. You can do this either by selecting Preset Size and then selecting the matching width and height values from the dropdown menu, or selecting Custom Size then entering the values in the fields that appear.
- Select your slideshow custom native ad template in the Template dropdown menu.
- Fill in the rest of the fields as needed, including the image URLs and destination URLs.
- Click Save Ad Item.