Richzilla Posted June 27, 2007 Share Posted June 27, 2007 I have recently setup a web marketing agency, but our tracking scripts are having some major issues. We have 2 codes which we place onto the mercahnts website. 1 is a Javascript and the other is a 1x1 pixel tracking call to our database. The problem is that we cannot get the tracking code to work with both versions of internet explorer. Sadly the majority of shoppers use IE as opposed to Firefox. Here's the codes - mId = merchant number cs = basket value it = items ordered oi = purchase number This goes in the header - <SCRIPT type="text/javascript"> function getCheckoutUrl(mId, cs, it, oi) { if (document.all) { var ticks = new Date().getTime(); var urlStr = "http://mysite/ProcessProductCheckout.ashx?mId=" + mId + "&it=" + it + "&oi=" + oi + "&cs=" + cs + "&tm=" + ticks; xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); if (xmlHttpRequest!=null) { xmlHttpRequest.open("GET", urlStr); xmlHttpRequest.send(null); } } } </SCRIPT> This goes into the body onload tag - <BODY onLoad="getCheckoutUrl(77, <?php echo $prodprice; ?>, 1, <?php echo $ordID; ?>);"> This is the main body - <!-- BEGIN my site tracking code --> <?php $_SERVER['REQUEST_TIME']; $ts = date(U); $browser = $_SERVER['HTTP_USER_AGENT']; if (!(stristr($browser, 'MSIE'))) { echo "<img border=\"0\" src=\"http://mysite/ProcessProductCheckout.ashx?mId=77&cs=".$prodprice."&it=1&oi=".$ordID."×tamp=".$ts."\" />"; } ?> <!--end tracking code--> So basically, the script in Firefox produces the pixel link and sends through the order inforamtion. Under IE the javascript doesn't work. We started off using just the pixel image for both IE and Firefox, but we found that the image was being cached under IE and not calling for a new image. Overall IE is causing us massive issues. Does anyone have a solution to the above code? Any help would be massively apprecaited. Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/ Share on other sites More sharing options...
RichardRotterdam Posted June 27, 2007 Share Posted June 27, 2007 Being lazy as I am I only paid notice to your last comment that the image is being cached by IE. Here is a trick you can apply. instead of reading the image url why not add a little random variable behind your image here is an example imgUrl="pixel.jpg?rand="+Math.random() and that solves the image being cached in IE Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-284068 Share on other sites More sharing options...
Richzilla Posted June 27, 2007 Author Share Posted June 27, 2007 Thanks for the input Kat, but the timestamp info at the end is there to do that. That didn't work either. The error now is with the javscript. I have a feeling that - 'new ActiveXObject' is teh source of the problem. Any further ideas people? Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-284136 Share on other sites More sharing options...
RichardRotterdam Posted June 28, 2007 Share Posted June 28, 2007 I took a better look at your script. If I am correct the script in the head section only works in IE since Firefox doesn't have ActiveXObject. have you tried to put that url in your IE browser manually? Something I also try is alerting the url in the script to check if there are no empty variables. Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-284740 Share on other sites More sharing options...
RichardRotterdam Posted June 28, 2007 Share Posted June 28, 2007 Something different came into mind maybe IE has problems with the image tag since the src is not a jpg or gif or whatever. maybe you should try to use an invisible iframe instead of image tag and don't use javascript at all <?php echo('<iframe width="0" height="0" src="http://mysite/ProcessProductCheckout.ashx?mId=77&cs='.$prodprice.'&it=1&oi='.$ordID.'×tamp='.$ts.'" ></iframe>'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-284849 Share on other sites More sharing options...
nogray Posted June 28, 2007 Share Posted June 28, 2007 use a more common AJAX approch to avoid any problems. The XMLHttpRequest works in IE 7 and other browsers, while ActiveXObject("Msxml2.XMLHTTP") only works in IE 6 and below something like this will be a better choice var xmlHttp; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Your browser does not support AJAX!"); return false; } } } Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-285249 Share on other sites More sharing options...
Richzilla Posted June 29, 2007 Author Share Posted June 29, 2007 Hi All, Thanks very much for your input. The change of image has sadly not worked. I fear that this mercahnts server is stopping any tracking calls using images. It's very strange, but even a very simple page that works on other sites doesn't with this merchant. I like the idea of the AJAX above. Any chance you can ammend the code so that it includes the tracking call? I have no idea about AJAX and I have no idea whre to put the call. Thnaks for the help so far guys. I feel that we are very close. Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-285687 Share on other sites More sharing options...
Richzilla Posted June 29, 2007 Author Share Posted June 29, 2007 Hi All, The AJAX code hasn't worked. We have decided to go back to square 1 with all of this. The single pixel call is working on some sites but not on others. There really is absolutely no explanation for this. The code for the call is below - <!---- Shop Submit Tracking Code ----> <?php $_SERVER['REQUEST_TIME']; $ts = date(U); echo "<img border=\"0\" src=\"http://mysite/ProcessProductCheckout.ashx?mId=77&cs=".$costvar."&it=1&oi=".$order_id."×tamp=".$ts."\" />"; ?> <!---- End Shop Submit Tracking Code ----> When this code runs it assimilates the data correctly and as far as i can see it should work, but it doesn't. This works 100% in Firefox and on some sites in IE. WHat is possibly going wrong? We've gone round and round in circles on this for a week and no solution is imminent. Is there anything that we can do now? Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-285746 Share on other sites More sharing options...
RichardRotterdam Posted June 29, 2007 Share Posted June 29, 2007 This is basicly what your ajax script would look like this will work both in Firefox and IE read the comments i have made you will need to adjust the function sendRequest() to your needs function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('Problem creating the XMLHttpRequest object'); } return req; } // Make the XMLHttpRequest object var http = createRequestObject(); //calls the script on server function sendRequest() { //user data adjust these to your needs var mId ="merchant number"; var cs = "basket value"; var it = "items ordered"; var oi = "purchase number"; var ticks = new Date().getTime(); //the url that is called externaly var urlStr = "http://mysite/ProcessProductCheckout.ashx?mId=" + mId + "&it=" + it + "&oi=" + oi + "&cs=" + cs + "&tm=" + ticks; //the call is being made here http.open('get', urlStr); //uncomment the next line if you want to return a value on your page //http.onreadystatechange = handleResponse; http.send(null); } /*this function you wont need but you can use it for testing purposes create a tag in your body html with result as id for this to work example <div id="result"></div>*/ function handleResponse() { if(http.readyState == 4 && http.status == 200){ // Text returned FROM the server script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById("result").innerHTML = response; } } } Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-285764 Share on other sites More sharing options...
Richzilla Posted June 29, 2007 Author Share Posted June 29, 2007 Hi Team, Thank you all so much for the help. The actual reason for all this headache is that those b@starrds at Microsoft make you jump through hoops to set a cookie on someones browser. We have to setup a p3p.xml file to get validation for our cookie. It's proving to be almost impossible. Does anyone know who to ask to help us out? I've been doing it all day and I'm about ready to scream and go crazy!! If any of you lot know, here's the problem - Header http setup for the http://feeds.shopsubmit.co.uk/ProcessProductCheckout.ashx file <% Response.AddHeader 'P3P', 'policyref="http://feeds.shopsubmit.co.uk/w3c/p3p.xml", CP="NON DSP ADM DEV PSD CUSo OUR IND STP PRE NAV UNI"' %> <%@ WebHandler Language="C#" CodeBehind="ProcessProductCheckout.ashx.cs" Class="ShopSubmitWeb.ProcessProductCheckout" %> p3p.xml file - http://feeds.shopsubmit.co.uk/w3c/p3p.xml Bascially it's saying that the cookie is invalid as it can't find the privacy document which is clearly stated a the top of our xml file. I'm going crazy over this!!! Quote Link to comment https://forums.phpfreaks.com/topic/57402-pixel-tracking-issues-with-internet-explorer/#findComment-286167 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.