I have a similar problem.
Problem: My client has a contact page with a form. After the user fills in all the fields of the form, there is a check (to check whether the user has completed all the fields correctly). After verification, the user is redirected to the email server page. There is no Success or Thank you page. So I needed to put the Adwords tag after validating the form.
Decision:
The check was performed as follows:
var missinginfo = ""; var f = document.forms["CONTACT"]; if (f.name.value == ""){ missinginfo += "\n - name";} . . . if (missinginfo != "") { missinginfo ="_____________________________\n" + "Empty Field" + "incorrectly filled" + missinginfo + "\n_____________________________" alert(missinginfo); return false; }
So, I added this code snippet:
else if(missinginfo == ""){ //Check if the form was filled correctly adw_conv(); //Function Name return false; } function adw_conv(){ var img = new Image() //Creates an image using JS to make the request img.src = "http://www.googleadservices.com/pagead/conversion/123456789/?label=-8bcaCNHv6AIQl_v8_QM&guid=ON&script=0"; img.onload = function(){ var form = document.getElementsByName('CONTACT')[0]; form.submit(); }}
Thus, after checking the form and before the website redirects the user to the email page, the conversion of Adwords will be launched!
Bruno Brandão Jan 17 2018-12-12T00: 00Z
source share