Jump to content
yannux

[Tips] clickurl inside iframe

Recommended Posts

Hi,

Here is some javascript to easy have click count  with swiffy ads inside an iframe.

In Revive adserver : create HTML Generic Banner, replace [URL_OF_YOUR_HTML_SWIFFY_FILE] with the url of your swiffy html file.

We give clickurl with magicmacro

 

<iframe src="[URL_OF_YOUR_HTML_SWIFFY_FILE]?clickurl={clickurl}" width="100%" height="90px" frambedorder="0"></iframe>

 

Edit your swiffy html file, go down and replace last <script> block 

<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer'), swiffyobject, {});
stage.start();
</script>

With

<script>
    // !!!!!!! Ads destination link !!!!!!
    var lienClient = '';


    var clickurl = /clickurl=([^&]+)/.exec(document.location.href)[1];

    var swiffycontainer = document.getElementById('swiffycontainer');

    if (clickurl) {
        var parent  = swiffycontainer.parentNode;
        var wrapper = document.createElement('a');
        wrapper.setAttribute("href", clickurl + lienClient);
        wrapper.setAttribute("target", "_blank");
        // set the wrapper as child (instead of the element)
        parent.replaceChild(wrapper, swiffycontainer);
        // set element as child of wrapper
        wrapper.appendChild(swiffycontainer);
    }

    var stage = new swiffy.Stage(swiffycontainer, swiffyobject, {});
    stage.start();
</script>

 

Thanks to http://forum.revive-adserver.com/topic/3194-generic-html5-banner-clicks-tracking/  and http://stackoverflow.com/questions/6938248/insert-a-div-element-as-parent

 

Edited by yannux
Code cleaning

Share this post


Link to post
Share on other sites

clicks count not working  with  iframe like 

<iframe src="[URL_OF_YOUR_HTML_SWIFFY_FILE]?clickurl={clickurl}" width="100%" height="90px" frambedorder="0"></iframe>
Edited by pankaj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×