To make your banner clickable, make sure that a click tag is set up correctly. You can add a clickTag
variable in several ways:
Here is an example of how to add a clickTag
to div
element in an HTML5 banner:
-
Set ID (or class name) value for
clickTag
area/layer:<div class="click-layer" id="clickLayer"></div>
-
Take this particular element by its id (or class name) and set the
onclick
function to it. Place this script somewhere below the element in the HTML document (to make sure the element is created earlier than the code is executed):<script> var clickArea = document.getElementById('clickLayer'); var clickTAGvalue = dhtml.getVar('clickTag', 'http://www.example.com'); var landingpagetarget = dhtml.getVar('landingPageTarget', '_blank'); clickArea.onclick = function() { window.open(clickTAGvalue,landingpagetarget); } </script>
You can set a clickTag
as <a> element's href
value. To do that, follow these steps:
-
Set id (or class name) value to each <a> element. You may leave
href
values not yet defined here:<div id="links"> <div class="links-title"></div> <a class="link link-1" id="link-1" target="_blank">My first link</a> <a class="link link-2" id="link-2" target="_blank">My second link</a> <a class="link link-3" id="link-3" target="_blank">My third link</a> <a class="link link-4" id="link-4" target="_blank">My fourth link</a> </div>
-
Below in the banner's HTML code use this script to get a particular <a> element and set a
href
attribute for it. Eachhref
attribute may inherit theclickTag
variable value from the Adform system or some static URL if the banner is being tested locally:<script> document.getElementById('link-1').setAttribute('href', dhtml.getVar('clickTag', 'http://www.example-1.com')); document.getElementById('link-2').setAttribute('href', dhtml.getVar('clickTag2', 'http://www.example-2.com')); document.getElementById('link-3').setAttribute('href', dhtml.getVar('clickTag3', 'http://www.example-3.com')); document.getElementById('link-4').setAttribute('href', dhtml.getVar('clickTag4', 'http://www.example-4.com"')); </script>
-
Register multiple click tags to manifest.json file before the banner is uploaded to the system, e.g.,
{ "version": "1.0", "title": "Banner-Sample-930x400", "description": "", "width" : "930", "height": "180", "events": { "enabled": 1, "list": { } }, "clicktags": { "clickTag": "http://www.example-1.com", "clickTag2": "http://www.example-2.com", "clickTag3": "http://www.example-3.com", "clickTag4": "http://www.example-4.com", }, "source": "index.html" }
You can create a clickTag
element and add a JavaScript click functionality directly inline. See the samples below.
-
How to create a clickable
div
with id "clicktagger" and a mouse pointer that changes on mouseover/mouseout events.<div id="clicktagger" onclick="javascript:window.open(dhtml.getVar('clickTag'),'_blank');" onmouseover="javascript:this.style.cursor='pointer';" onmouseout="javascript:this.style.cursor='auto';"></div>
-
How to create a hyperlink element
<a href=''>
, setclickTag
variable value ashref
attribute, and append it to a document body.<script> window.onload = function() { var link = document.createElement('a'); link.style.display = 'block'; link.href = dhtml.getVar('clickTag'); link.target = dhtml.getVar('landingPageTarget'); document.body.appendChild(link); } </script>
To dynamically redirect the clickTag
value to another landing page, use the ;cpdir= referrer. E.g.,
var redirect = 'http://www.example.com'; var custom = ';cpdir=' + redirect; window.open(clickTag + custom, landingpagetarget);
Note
The referrer will not work while testing locally or in an HTML5 Studio environment. The creative must be served through the platform for this kind of redirect to function properly.
If you created a banner on an external platform, and now are using it for your campaigns in Adform, you need to make sure that a click tag is set up correctly so that your banner is clickable.
To set up a global click tag:
-
Drag and drop your zipped banner into Adform Studio. If no click tag is detected in your banner, a pop-up notification will appear suggesting to add one. In case the message doesn't appear, proceed to the following steps.
-
In the top-right corner, click .
-
Select Global ClickTAG from the dropdown list.
-
In the window that appears, enter the desired landing page.
-
Click Proceed.
If you need to have multiple click tags on the same banner, do the following:
-
Set ID or (class name) for click elements:
<body> <div id="element"> <div id="linkbox"> <a id="left">My Link1</a> <a id="center">My Link2</a> <a id="right">My Link3</a> </div> </div>
-
Define a click tag value for each
clickTag
instance. Values should get landing page URLs from the Adform system (dhtml.getVar
) once the banner is placed there or you may use some static value for local testing. Collect allclickTag
instance elements from HTML document by usinggetElementById
orgetElementsByClass
methods. Set theonlick
function to each element separately. Place this script somewhere below the click elements in the HTML document (to make sure the elements are created earlier than the code is executed):<script> clickTAGvalue = dhtml.getVar('clickTag', 'http://www.adform.com'); clickTAGvalue2 = dhtml.getVar('clickTag2', 'http://html5toolkit.adform.com/'); clickTAGvalue3 = dhtml.getVar('clickTag3', 'http://site.adform.com/resources/creative-space/'); landingpagetarget = dhtml.getVar('landingPageTarget', '_blank'); var center = document.getElementById('center'); var left = document.getElementById('left'); var right = document.getElementById('right'); center.onclick = function() { window.open(clickTAGvalue,landingpagetarget); } left.onclick = function() { window.open(clickTAGvalue2,landingpagetarget); } right.onclick = function() { window.open(clickTAGvalue3,landingpagetarget); } </script>
A click on a particular click layer area calls a function that opens a window with an inherited particular
clickTag
URL value from the Adform system or the particular fallback static URL (when testing locally). When a banner is uploaded to the system,getVar
returns the URL defined in the system next to the asset. When a banner is being tested locally, a fallback URL is taken as if aclickTag
is 'null' so far. -
Register multiple click tags to manifest.json file before the banner is uploaded to the system, for example:
{ "version": "1.0", "title": "Banner-Sample-580x400", "description": "", "width" : "580", "height": "400", "events": { "enabled": 1, "list": { } }, "clicktags": { "clickTag": "http://www.adform.com", "clickTag2": "http://html5toolkit.adform.com/", "clickTag3": "http://site.adform.com/resources/creative-space/", }, "source": "index.html" }
Here is a code snippet on how to correctly add click tags for banners that are in the mobile category:
var banner = document.getElementById('banner'); var container = document.getElementById('container'); banner.addEventListener('click', function() { mraid.open(Adform.getClickURL('clickTAG')); }); container.addEventListener('click', function() { mraid.open(Adform.getClickURL('clickTAG2')); });