Ads: Include at least one 'ClickTag' in your html?

@Bendora @thebrownsquare
Hey guys,
good to hear that you got the clicktag running.
I also try to add an IAB clicktag (Austrian Ad) to my hype scene, but it doesn't work.
Hope you can help me. I created one HTML Widget and added this code:

<script type="text/javascript">
    var getUriParams = function() {
        var query_string = {}
        var query = window.location.search.substring(1);
        var parmsArray = query.split('&');
        if(parmsArray.length <= 0) return query_string;
        for(var i = 0; i < parmsArray.length; i++) {
            var pair = parmsArray[i].split('=');
            var val = decodeURIComponent(pair[1]);
            if (val != '' && pair[0] != '') query_string[pair[0]] = val;
        }
        return query_string;
    }();
</script>
<a id="IAB_clicktag" href="" target="_blank" style="width:300px; height:600px; display:block"></a>
<script>
    document.getElementById('IAB_clicktag').setAttribute('href', getUriParams.clicktag);
</script>

In an empty html-file the script works. I also tried the exact code Bendora used. Both ways it doesn't work in hype. I can't set the clicktag url via ?clicktag=. The href stays "undefined".
I even encoded the URL ( http%3A%2F%2F instead of http:// ).
Do you have any idea what I'm doing wrong? Have you added any kind of preloader for the whole ad? Or did you give the html widget an ID?
thanks alot.

You’re going to want to run this in the <head>:

<script type="text/javascript">
    var getUriParams = function() {
        var query_string = {}
        var query = window.location.search.substring(1);
        var parmsArray = query.split('&');
        if(parmsArray.length <= 0) return query_string;
        for(var i = 0; i < parmsArray.length; i++) {
            var pair = parmsArray[i].split('=');
            var val = decodeURIComponent(pair[1]);
            if (val != '' && pair[0] != '') query_string[pair[0]] = val;
        }
        return query_string;
    }();
</script>

Place this within a regular rectangle element:

<a id="IAB_clicktag" href="" target="_blank" style="width:300px; height:600px; display:block"></a>

And you’ll need to run this as an ‘on scene load’ JavaScript function:

document.getElementById('IAB_clicktag').setAttribute('href', getUriParams.clicktag);

The window.location.search.substring(1); function is getting the URI of the iframe which represents your HTML widget, not the actual HTML page that the document is loaded in (which is what happens when you run this in a single .html page).

HTML widgets are iframes, so they are a bit more insulated from the outside world. When you run the code you pasted in an iframe, it is being loaded in an HTML page like http://example.com/documentName.hyperesources/iframe-1.html.

2 Likes

perfect! thanks alot.

Give it a try… I will be waiting on a feedback, Michi.

It worked perfectly! :slight_smile:

1 Like

EDIT:

mhhhhh I fixed it. Not sure what the problem was in the first try. But adding an function to the rectangle instead putting an link inside works on Android and iOS.

Sorry I have to pull the topic back up.
The solution works in all browsers, but not on iOS and Android.
I also tried opening the link with an JavaScript and window.open. This also works on desktop, but not on mobile :confused:
So i tried to step back:
Rectangle with direct link on it works on iOS
Rectangle containing an link like done above doesn't work.

Also launching the JavaScript function direct from the rectangle doesn't work :frowning:

what I forgot to mention:
it's like blocking the window. I tried it with function that stops a video and opens an link. The video stops, but the link does not open.

Can you try:

<script type="text/javascript">

function clickURLTriggered() {
  window.open('%%CLICK_URL_UNESC%%',
  '_self' // <- Use _self here to open in the same window.
);}
</script>

It may be that that it doesn’t like opening in a new window?

Hi,

I cant get the click tag to work on a creative supplied by a client, I am trying to upload the creative to google dfp, but it wont work because it says there is no click tag within the code.

I have 2 bits of code as below that I need to get into a html 5 code, but am not sure where to put it?

please please please can someone help?

Code snippet 1: var clickTag = “http://www.ping.com/clubs/ironsdetail.aspx?id=21292”;

Code Snippet 2: onclick=“javascript:window.open(window.clickTag)”

Thanks Everyone!

When you upload your code, DFP is looking for one of the Macros which will be replaced when the ad is loaded. Something like %%CLICK_URL_UNESC%%

So you can use this code:

var clickTag = "%%CLICK_URL_UNESC%%";

… and then the actual URL which you are sending people to with the ad will be added elsewhere in DFP.

Hi Daniel,

Where abouts do I upload this code?

As I have done it with another client where it worked, but the code won’t work with this specific client?

I assume that this code is in the head of your document. You can edit the contents of the <head>… of your exported .html file by clicking on ‘Edit HTML Head’ in the Document Inspector.

Hi Daniel,

I am really struggling to get this to work, are you able to have a look at it for me?

5 posts were split to a new topic: Adding Clicktag to DCM banner

By “Over type the URL (WWW.REPLACE.COM) with:” Do you mean replace? or put on the line above?

I use this method in Hype

  1. Add following code to the Head
    script type=“text/javascript”> var clickTag = “http://www.google.com”; </script
    (add < before and > after, this forum hides the code, hence I left these out above)

  2. On mouse click (border) - Run Javascript (name function ExitTag)
    window.open(window.clickTag);

<script type="text/javascript"> var clickTag = "http://www.google.com"; </script>

Use the code tags. When posting you will see this menu bar

Code tag icon highlighted here in red.

hi All… im newbie here, as i read from above, it how to implement in button. #cmiiw

and how to make click tag banner ads, is clickable in all area banner ? so not only on a button.

thanks

The most common approach is to place an empty/invisible rectangle as the top-most element in your Hype document and have that trigger the clickTag action.

The alternative is to edit Hype’s exported HTML and add an onclick action to the main div or surround Hype’s content in a div with this action.

ahmmm got it…
thank you for the answere

1 Like