Google AdWords Conversion Tracking with AJAX form

2019-03-09 21:26发布

问题:

This question already has an answer here:

  • How to track a Google Adwords conversion onclick? 5 answers

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!

回答1:

Use an IFRAME to call an HTML file with the conversion tracking code on it.

http://www.benjaminkim.com/?p=24



回答2:

AFAIK the best way to do it in your scope is using the no-script image.

I will show you 2 ways:

  1. You can put it on your "thank you HTML" as is, with escaped characters where necesary.

  2. 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.



回答3:

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.



回答4:

Try dynamically inserting the tracking code in the page after the user is converted.