If your site is using AJAX, then the traditional implementation of AdWords, YSM, MSN, etc. conversion tracking may not work. The solution is to use an IFRAME to call a file with the conversion tracking code (pixel) on it.
IFRAMES with Javascript:
function ppcconversion() {
var iframe = document.createElement('iframe');
iframe.style.width = '0px';
iframe.style.height = '0px';
document.body.appendChild(iframe);
iframe.src = 'http://www.yourdomain.com/path_to_file_with_code';
};
Where should I put this function?
Must it reside in de file that is called by AJAX (the one that submits the form?)
@Maarten: The function should be part of the AJAX code. A separate HTML file should have the conversion tracking code.
i don’t think it works, i don’t see in fiddler all the calls that i see when i load the tracking html page in the browser…
@Boaz: Strange. It should work. Can you provide more details?
I like this approach. I’m testing it out right now. Haven’t be able to get a conversion tracked yet.
Does this function code just go in the ajax success function or do you have to call it there and place it outside? I’m not seeing the iframe being served…
@Thomas: call it in the success function and place it outside.
Thank you. Good simple solution!
Just wanted to say I’ve used this twice now and it has worked great for me. Thanks for your awesome solution!
This worked perfectly for me. I added into the file being called via Ajax and it worked! Before-hand it was just loading the from the conversion code which was stopping the conversions working.
Very nice snippet, all conversion tracking can now be done in editable, simple HTML files, without having “anyone” go through source codes.
AND it works perfectly well with Ajax Calls.
I just had an issue where two pages were working (normal POST / redirect) and two which were not (AJAX post / content replace), now everything works just fine!
Thank you so much
I been doing a research on how to make this conversion works on my ajax pop-up forms.
We will try it now. If it works it’s an amazing workaround 😀