After doing a little research, would something like this work?
function ajax_submit(formid, redirect){
var formData = new FormData( $(formid)[0]);
$.ajax({
type: $(formid).attr('method'),
url: $(formid).attr('action'),
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
enctype: 'multipart/form-data',
mimeType: 'multipart/form-data',
formid: formid,
success: function(data, textStatus, jqXHR) {
if (ghjb_d) console.log('success', textStatus, data, jqXHR, this.formid);
// thanks_message(this.formid);
},
error: function(jqXHR, textStatus, errorThrown) {
if (ghjb_d) console.log('error', textStatus, errorThrown, jqXHR);
},
complete: function(jqXHR, textStatus) {
if (ghjb_d) console.log('complete', textStatus, jqXHR);
thanks_message(this.formid, textStatus);
/* Conversion Tracking Start */
var google_conversion_id = YOUR_CONVERSION_ID_HERE;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "YOUR_CONVERSION_LABEL_HERE";
var google_remarketing_only = false;
$.getScript('//www.googleadservices.com/pagead/conversion.js');
var image = new Image(1, 1);
image.src = "//www.googleadservices.com/pagead/conversion/YOUR_CONVERSION_ID_HERE/?label=YOUR_CONVERSION_LABEL_HERE&guid=ON&script=0";
/* Conversion Tracking End */
// if (redirect != null && redirect != undefined) {
// window.location.href = redirect;
// }
},
});
return false;
}
Hey @bsteinlo, yes what you have done here would be a good way to do it.
We could add a submit hook for your js and then you’d just add your own code to that hook. That’d be the best way to do it, that hook would be called once the form is submitted. Any other hooks that would help out your funnel tracking?
Ideally we give you the hooks you need so that you don’t have to edit the plugin code so nothing has to be merged when a new version of the plugin is released.
Hey, thanks for getting back to me!
A submit hook for the JS would be ideal for that funnel tracking. I think that would be it.
I just wasn’t sure if I could do the AdWords tracking basic tracking code, or how to go the async route. Any thoughts there?
For anyone else interested in this, I solved it by using the conversion tracking code for a button click. I then put this code into my page template
<script type="text/javascript">
/* <![CDATA[ */
goog_snippet_vars = function() {
var w = window;
w.google_conversion_id = your-conversion-tracking-id;
w.google_conversion_label = "your-conversion-label";
w.google_remarketing_only = false;
}
goog_report_conversion = function(url) {
goog_snippet_vars();
window.google_conversion_format = "3";
var opt = new Object();
opt.onload_callback = function() {
if (typeof(url) != \'undefined\') {
window.location = url;
}
}
var conv_handler = window[\'google_trackConversion\'];
if (typeof(conv_handler) == \'function\') {
conv_handler(opt);
}
}
/* ]]> */
</script>
and then I am firing the goog_report_conversion();
function on the ajax_submit
complete request.
-
This reply was modified 8 years, 4 months ago by
bsteinlo.