Question

I need to register multiple conversions with google from a single page. In Chrome and Firefox, this works fine. In IE, it seems that the page / call is getting cached and subsequently only one conversion is sent.

I have tried adding no-cache meta tags, but this did not work.

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

I have also tried calling completely separate pages for each conversion in hopes of circumventing the caching problem. This also did not work.

Here is the conversion page that is called. It is loaded into an iframe.

<head>

<script type="text/javascript">


    var google_conversion_id = 1070072355;
    var google_conversion_language = "en";
    var google_conversion_format = "3";
    var google_conversion_color = "ffffff";
    var google_conversion_value = 0;
    var google_conversion_label;
    var googleConversionType = 1; //default to 1

    //check if we need to to GCR
    var GCR = QueryStringGet("G");
    if (GCR && GCR != "" && GCR != 0) {
        googleConversionType = GCR;
    }

    /*
    CONVERSION TYPES:
    1- Single Lead: V-v8CMnc_gEQo4Sg_gM
    2- Multiple Leads: oHF7CLHf_gEQo4Sg_gM
    3 - Campaign Single: CmYQCMHd_gEQo4Sg_gM
    4 - Consultation: aSv7CLne_gEQo4Sg_gM
    */
    //set the label per conversion type
    if (googleConversionType == 1) {
        google_conversion_label = "V-v8CMnc_gEQo4Sg_gM";
    }
    else if (googleConversionType == 2) {
        google_conversion_label = "oHF7CLHf_gEQo4Sg_gM";
    }
    else if (googleConversionType == 3) {
        google_conversion_label = "CmYQCMHd_gEQo4Sg_gM";
    }
    else if (googleConversionType == 4) {
        google_conversion_label = "aSv7CLne_gEQo4Sg_gM";
    }

    //retrieves a value from the querystring
    function QueryStringGet(ji) {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i = 0; i < gy.length; i++) {
            ft = gy[i].split("=");
            if (ft[0] == ji) {
                return ft[1];
            }
        }
    }
    </script>
    <script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"></script>
    <noscript>
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1070072355/?label=V-v8CMnc_gEQo4Sg_gM&amp;guid=ON&amp;script=0"/>
    </div>
    </noscript>

    <title></title>
</head>

Here is the code to load the page into the iframe

function GoogleConversionRegister(pageNum) {

    if (!pageNum || pageNum == 0)
        pageNum = 1;

    var iframe = document.createElement('iframe');
    iframe.style.width = '0px';
    iframe.style.height = '0px';
    document.body.appendChild(iframe);
    iframe.src = 'http://www.nirshamim.co.il/google/conversion_' + pageNum + '.html?G=' + googleConversionType + '&tile=' + (Math.random() * 100000);}

Here are the results from Fiddler:
Chrome
IE

Was it helpful?

Solution

In order to circumvent IE's caching mechanism, I was forced to manually populate the iframe with the desired javascript (rather than load an external page).

The code:

var iframe;
if (document.createElement && (iframe = document.createElement('iframe'))) {
    iframe.name = iframe.id = 'conversion_' + pageNum;
    iframe.width = 0;
    iframe.height = 0;
    document.body.appendChild(iframe);
}
if (iframe) {
        var iframeDoc;
        if (iframe.contentDocument) {
            iframeDoc = iframe.contentDocument;
        }
        else if (iframe.contentWindow) {
            iframeDoc = iframe.contentWindow.document;
        }
        else if (window.frames[iframe.name]) {
            iframeDoc = window.frames[iframe.name].document;
        }
        if (iframeDoc) {
            iframeDoc.open();
            iframeDoc.write('<html><body><script language=javascript>var google_conversion_id = XXXXX; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_value = 0; var google_conversion_label = "XXXX";</script><script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"></script></body></html>');
            iframeDoc.close();
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top