Jump to content

[Tips] clickurl inside iframe


yannux

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
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...