I have a google adwords conversion tracking code that I need to implement basically on an onclick event. The form I am tracking submits information using AJAX and then renders a Thank you message to the page by replacing the form's div with the thank you HTML ( $('div').html("thank you....., etc"); )
I'm wondering if there's a way to a) trigger a conversion track when the SUBMIT button is clicked, or b) if I include the google script to be posted to the site in the html() function that writes to a div, will that track the conversion? or c) Any other thoughts on doing this?
I've searched a bit on this but haven't had much luck.... Thanks!
Use an IFRAME to call an HTML file with the conversion tracking code on it.
http://www.benjaminkim.com/?p=24
AFAIK the best way to do it in your scope is using the no-script image.
I will show you 2 ways:
You can put it on your "thank you HTML" as is, with escaped characters where necesary.
Or... Just put an empty image tag like this anywhere on your HTML document:
<img src="" width="1" height="1" style="visibility:hidden;" alt="" id="myconversion" />
Then add this line of jQuery to your script before or after the your "thank you HTML":
$("#myconversion").attr("src","xxxxxxxxx");
Where xxxxxxxxx is the src attribute of the no-script image.
I have heard that the iframe method is unreliable. Dynamically inserting the script does work however as the conversion script uses document.write you have to do something like this http://www.webdeveloper.com/forum/showthread.php?t=195112 to load the script otherwise it doesn't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With