SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)

    Changing YAHOO ads every AJAX request

    Anyone have insight on how the yahoo ad serving script can be used to serve up ads up using JavaScript that isn't inline? I've attempted several things but it just seems like its impossible to do. Essentially, I would like to swap out a new round of ads per AJAX request. Any ideas? I've created a more friendly user interface for a site I'm working on but the thing is that the ads need to change every request since page refreshes are being eliminated. Otherwise, only a single impression may be tracked even though someone has visited essentially 100 pages, which is no good for the ad business. Any insight is appreciated.

    Also, has anyone had success finding a way to delay the yield manager until the page has fully loaded? Sometimes the yahoo yield manager can take 10+ seconds resulting in a poor user experience and slow load time. Any ideas for that? Essentially, it would be nice to fully load the page than request the ads without using obtrusive JavaScript which seems to be the only way yahoo knows to do things.

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,033
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Could you post a link to the script or (more preferably) the API of the script you're talking about?
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    This is the script:

    Its pretty much an unreadable pile of trash but yeah, its what I have to work with.

    Code JAVASCRIPT:
    (function () {
     
        var U = window.yld_mgr;
     
        if (typeof(U) != "object") {
            return
        }
     
     
        var H = "ym_";
        var L = 1990;
        var K = "default_" + Math.round(9999999999 * Math.random());
     
     
        U.is_data_call = U.request_type == "bc";
        U.non_ad_request_type = U.request_type == "bc" || U.request_type == "fc";
        U.is_multi_ad_call = U.slots ? true : false;
        U.is_sync_call = U.container_type == "js";
     
     
     
        U.proxy_url = "http://e.yieldmanager.net/chunkPasser.html";
     
     
     
        var F = (!navigator.userAgent.match(/AppleWebKit\/([^ ]*)/) && !navigator.userAgent.match(/opera/gi) && navigator.userAgent.match(/msie/gi));
     
     
     
     
        U.place_ad_here = function (Y) {
     
            if (U.is_data_call) {
                var X = yld_mgr.getDataCallUrl(Y);
                document.write('<iframe src="' + X + '" height=0px width=0px style="display:none">+</iframe>');
                return
            }
     
     
     
            if (U.is_sync_call) {
     
     
     
                if (yld_mgr.show_ad_sync) {
                    yld_mgr.show_ad_sync(Y)
                }
     
     
            } else {
     
     
                document.write("<div id='" + H + Y + "'></div>");
                if (yld_mgr.show_ad_here) {
                    yld_mgr.show_ad_here(H + Y)
                }
     
     
     
            }
     
     
        };
     
     
     
        U.getIndex = function (X) {
            return yld_mgr.call_index[X]
        };
     
     
     
        U.getDataCallUrl = function (X) {
            if (yld_mgr.fac_data_call_urls && yld_mgr.fac_data_call_urls.hasOwnProperty(X)) {
                return yld_mgr.fac_data_call_urls[X]
            } else {
                return ""
            }
        };
     
     
     
        U.getSlotName = function (X) {
            return H + U.slot_names[X]
        };
     
     
     
     
        U.getNumberOfSlots = function () {
            var Y = 0;
            for (var X in this.slots) {
                if (this.slots.hasOwnProperty(X)) {
                    Y++
                }
            }
            return Y
        };
     
        function C() {
            if (U.is_data_call) {
                A();
                if (!U.is_multi_ad_call) {
                    U.place_ad_here(K)
                }
                return
            }
            var X = D();
            S(X)
        }
     
     
     
        function S(X) {
            if (U.is_sync_call && !U.is_data_call) {
                document.write('<script type="text/javascript" src="' + X + '"><\/script>')
            } else {
                if (!U.is_multi_ad_call) {
                    U.place_ad_here(K)
                }
                var Y = document.createElement("script");
                Y.src = X;
                var Z = document.getElementsByTagName("head")[0];
                yld_mgr.script_element = Y;
                window.setTimeout(function () {
                    Z.appendChild(Y)
                }, 20)
            }
        }
     
     
        function E(Y, Z, X) {
            return [J("fmt" + Z, Y.ad_format_list, 1), J("sz" + Z, Y.ad_size_list, 0), I("fSz" + Z, G(Y.ad_fit_size) ? 1 : 0), W("dlv" + Z, Y.ad_delivery_mode), J("conTy" + Z, Y.content_type_list, 1), W("mrkr" + Z, Y.ad_marker), W("pltID" + Z, Y.palette_name), W("InvId" + Z, Y.inventory_id), J("rTg" + Z, Y.reporting_tag_list, 1), J("cCat" + Z, Y.cstm_content_cat_list, 1), W("sltId" + Z, (U.is_sync_call && U.is_multi_ad_call) ? (Z + "") : X), W("mxCnt" + Z, Y.max_count)].join("")
        }
     
     
     
        function V() {
            var X = U.content_topic_id_list || U.pub_content_cat_id_list;
            return [W("pubId", U.pub_id), W("site", U.site_name), (U.non_ad_request_type) ? W("rTy", U.request_type) : "", W("cntTy", U.container_type ? U.container_type : "dif"), W("inEnc", U.ad_input_encoding), J("cTopId", X, 0), W("rd", U.redirect_clk_wrapper), W("cDst", U.clk_dest), W("age", U.user_age), W("gdr", U.user_gender), W("inc", U.user_income), J("cSctn", U.cstm_sctn_list || U.site_section_name_list, 1), W("zip", U.user_zip), W("cty", U.user_city), W("dma", U.user_dma), W("st", U.user_state), W("ctry", U.user_country), W("enc", U.ad_output_encoding), W("aTgt", U.audience_targeting), W("ctLng", U.content_lang), W("pUsrId", U.partner_user_id), W("trace", U.trace_id)].join("")
        }
     
     
     
        function T(Y) {
            U.call_index = {};
            U.slot_names = {};
            var Z;
            if (!U.is_multi_ad_call) {
                Z = E(U, "", H + K);
                if (P(Y + Z.length)) {
                    return ""
                }
                U.call_index[K] = 0;
                U.slot_names[0] = K;
                return Z
            }
            var a = 0;
            var X = "";
            for (var b in U.slots) {
                if (U.slots.hasOwnProperty(b)) {
                    Z = E(U.slots[b], a, H + b);
                    if (P(Y + X.length + Z.length)) {
                        return X
                    }
                    X += Z;
                    U.call_index[b] = a;
                    U.slot_names[a] = b;
                    a++
                }
            }
            return X
        }
        function Q(X) {
            var Y = [(!X) ? I("tagTy", (U.is_sync_call ? "multi_secure" : "uni")) : "", (U.is_multi_ad_call) ? I("nAdP", U.getNumberOfSlots()) : "", I("rFrame", ((window.top == window.self) ? "1" : "0")), W("flv", R()), I("cb", (new Date()).getTime()), W("url", N())].join("");
            return Y
        }
        function B(a) {
            var c = "";
            var Z = W("ref", document.referrer);
            if (P(a + c.length + Z.length)) {
                return c
            }
            c += Z;
            a += Z.length;
            if (!U.non_ad_request_type && !G(U.disable_content_send)) {
                var Y = "";
                if (F) {
                    var b = L - 4 - a;
                    if (b > 0) {
                        var X = b > 500 ? 500 : b;
                        Y = M(document.getElementsByTagName("HTML")[0].innerHTML.substr(0, X)).substr(0, b);
                        Y = Y.replace(/%\w?$/, "")
                    }
                } else {
                    Y = M(document.getElementsByTagName("HTML")[0].innerHTML.substr(0, 500))
                }
                if (Y) {
                    c += I("byt", Y)
                }
            }
            return c
        }
     
     
     
        function D() {
            var X = U.enable_test_call ? "http://open.ad.yieldmanager.net/atest1?" : "http://open.ad.yieldmanager.net/a1?";
            if ("https:" == window.location.protocol) {
                X = U.enable_test_call ? "https://open.ad.yieldmanager.net/atest1?" : "https://open.ad.yieldmanager.net/a1?"
            }
            X += "V=4";
            X += V();
            X += Q(false);
            X += T(X.length);
            X += B(X.length);
            return X
        }
     
     
     
        function A() {
            yld_mgr.fac_data_call_urls = {};
            if (!U.is_multi_ad_call) {
                yld_mgr.fac_data_call_urls[K] = O(U, K);
                return
            }
            for (var X in U.slots) {
                if (U.slots.hasOwnProperty(X)) {
                    yld_mgr.fac_data_call_urls[X] = O(U.slots[X], X)
                }
            }
        }
     
     
     
        function O(Z, Y) {
            var X = U.enable_test_call ? "http://open.ad.yieldmanager.net/atest1?" : "http://open.ad.yieldmanager.net/a1?";
            if ("https:" == window.location.protocol) {
                X = U.enable_test_call ? "https://open.ad.yieldmanager.net/atest1?" : "https://open.ad.yieldmanager.net/a1?"
            }
            X += "V=3";
            if (!U.container_type || (U.container_type == "dif")) {
                U.container_type = "iframe";
                X += V();
                U.container_type = "dif"
            } else {
                X += V()
            }
            if (U.is_multi_ad_call) {
                U.is_multi_ad_call = false;
                X += Q(true);
                U.is_multi_ad_call = true
            } else {
                X += Q(true)
            }
            X += E(Z, "", H + Y);
            X += B(X.length);
            return X
        }
     
     
     
     
        function P(X) {
            if (F && (X > L)) {
                return true
            }
            return false
        }
     
     
     
        function N() {
            var X = "";
            try {
                if (top.location) {
                    X = top.location.href
                }
            } catch (Y) {}
            return X
        }
     
     
     
     
        function R() {
            var Y = new Object();
            Y.installed = false;
            Y.version = "0.0";
            if (navigator.plugins && navigator.plugins.length) {
                for (var X = 0; X < navigator.plugins.length; X++) {
                    if (navigator.plugins[X].name.indexOf("Shockwave Flash") != -1) {
                        Y.version = navigator.plugins[X].description.split("Shockwave Flash ")[1];
                        Y.installed = true;
                        break
                    }
                }
            } else {
                if (window.ActiveXObject) {
                    for (X = 2; X < 10; X++) {
                        try {
                            oFlash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + X);
                            if (oFlash) {
                                Y.installed = true;
                                Y.version = X + ".0"
                            }
                        } catch (Z) {}
                    }
                }
            }
            if (!Y.installed) {
                return "nf"
            }
            return Y.version
        }
     
     
     
     
        function M(X) {
            if (X) {
                if (typeof(encodeURIComponent) == "function") {
                    return encodeURIComponent(X)
                } else {
                    return escape(X)
                }
            }
            return X
        }
     
     
     
        function I(Y, Z) {
            var X = "";
            if (Z) {
                X += "&" + Y + "=" + Z
            }
            return X
        }
     
     
     
        function W(X, Y) {
            return I(X, M(Y))
        }
     
     
     
        function J(a, X, b) {
            var Y = "";
            if (X && X.length) {
                Y += "&" + a + "=" + (b ? M(X[0]) : X[0]);
                for (var Z = 1; Z < X.length; Z++) {
                    Y += "," + (b ? M(X[Z]) : X[Z])
                }
            }
            return Y
        }
     
     
     
     
     
        function G(X) {
            return parseInt(X, 10)
        }
        C()
    })();


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •