views:

814

answers:

0

Hi,

I have a contact form on my site that operates with a rails remote_form_for. After someone submits the form, the html in that div gets replaced with a success message instead of the entire page reloading (the reasons for doing this aren't too relevant...but basically this contact form is way below the fold and I don't want the page to refresh back to the top if there are any errors/success messages etc).

I'm trying to track google adwords conversions to see how many visitors submit a contact form. The javascript they gives you looks like this:

<!-- Google Code for Contact Tutor Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = SOME_NUMBER;
var google_conversion_language = "en_US";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "SOME_LABEL";
//-->
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"&gt;
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/SOME_NUMBER/?label=SOME_LABEL&amp;amp;guid=ON&amp;amp;script=0"/&gt;
</div>
</noscript>

The problem is if I put this in the partial for the "success" message of the remote_form_for it doesn't track any of the conversions!

I guess my question is, how will browsers execute the javascript in an Ajax call like that where the html in a div is getting replaced with some new html?

I tested it a bit by putting an "alert('hey')" in the first block of javascript. It gets executed. I then tried extracting the javascript from that URL http://www.googleadservices.com/pagead/conversion.js and pasting it directly in...it seems to get executed now and tracks some conversions - but appears to be under reporting. I also tried commenting everything and just using the image tag to track conversions. This also gets some but appears to under report.

The under reporting part is difficult to gauge but it appears to be pretty significant...50% maybe? I'm wondering if it is a difference in how browsers are executing the javascript. I wouldn't be opposed to setting up my own conversion tracking so I could be more confident in it...but I'd need to figure out how to detect the cookie adwords sets, etc.

Any ideas?