AdWords
5.3K members online now
5.3K members online now
Get started with AdWords - learn the basics to get set up for success
Guide Me
star_border
Reply

Conversions script not triggering after form submission.

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi, We have added conversions script that will trigger after the form submission on this page.

 

The form on our website doesn't have a thank you page. Instead we show the thank you message on the same page after we submit the form and we get the success response. Hence we modified the script and dynamically appended the script tags once we got success response after submitting the form. We have added the code in a function that is called after we get success response (after submitting the form). But the script was not working as conversion.js is a downloadable file. Then again we modified the above script as follows:
 
* <![CDATA[ */
var google_conversion_id = <conversion-id goes here>;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "<conversion-label goes here>";
var google_remarketing_only = false;
/* ]]> */
 
 
var externalScript3 = document.createElement('noscript');
var divElement = document.createElement('div');
divElement.style.display = 'inline';
var imgElement = document.createElement('img');
imgElement.setAttribute('height', '1');
imgElement.setAttribute('width', '1');
imgElement.setAttribute('alt', '');
imgElement.setAttribute('src', '//www.googleadservices.com/pagead/conversion/<conversion-id>/?label=<conversion-label>&guid=ON&script=...');
divElement.appendChild(imgElement);
externalScript3.appendChild(divElement);
document.head.appendChild(externalScript3);
 
Even after modifying the above script we unable to track conversions. Can anyone let us know where we are going wrong and whats the correct way. Are we heading in the right direction. Do we have the correct javascript conversions code or do we need any other js code as we don't have a separate "Thank You" page. Should we copy the code in conversion.js file and paste it below the variable declarations.
 
Also, we have re-marketing script on the website. If we change the variable scope to global (remove "var" keyword) in the above code, will it impact the re-marketing script.
 
Thanks in advance.
2 Expert replyverified_user

Conversions script not triggering after form submission.

Rising Star
# 2
Rising Star

Because you are using an embedded form, your best option would be to configure it to go to a thank you page:

http://developers.marketo.com/rest-api/assets/forms/examples/

 

 

Conversions script not triggering after form submission.

Top Contributor
# 3
Top Contributor

Hi Rajeev S.,

Is your code on the original page or on the delivered content? Scripts delivered through AJAX or callbacks do not run.

The easiest thing for you to do is simply return the image part of the script and display it if the transaction is successful.

The code you're showing won't work. That's because your are placing the code in the noscript element (externalScript3). You can only include pure html in the noscript portion.

As an alternative, create a javascript function on the host page, similar to what you have above.

 

function recordConversion() {

 var divElement = document.createElement('div');
 divElement.style.display = 'inline';
 var imgElement = document.createElement('img');
 imgElement.setAttribute('height', '1');
 imgElement.setAttribute('width', '1');
 imgElement.setAttribute('alt', '');
 imgElement.setAttribute('src', '//www.googleadservices.com/pagead/conversion/<conversion-id>/?label=<conversion-label>&guid=ON&script=...');
 divElement.appendChild(imgElement);
 document.body.appendChild(divElement);

}

When you get the success code returned, call this function. Be sure to fill in the correct conversion-id and conversion-label. You won't need any of that other stuff.

Caution, provided code has not been thoroughly tested. Be sure to do that before making it live. Mock up a page with the mechanics for submitting the form and receiving the response. First, make sure the script is not throwing errors. You'll need to activate the debugger on your browser. After confirming there are no script errors, you'll need to click on your own ad, then go to the mock up page and submit the form. A conversion should be recorded at that point, but it may not show up right away in the AW UI.

 

Best of Luck!

 

Pete

 

petebardo -- Deadhead doing AdWords

Conversions script not triggering after form submission.

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi Pete,

 

Is your code on the original page or on the delivered content? We are using a Marketo onSuccess() function which is there on the page itself and triggers after successful submission of the form. What we do in the function is we hide the form and display the thank you message. Within this function we are triggering the script which I've posted in my query above. Also would like to provide you the original script:

 

<!-- Google Code for Gartner CASB Market Report Download Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = <conversion-id goes here>;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "<conversion-label goes here>";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/<conversion-id>/?label=<conversion-label>&guid=ON&...>
</div>
</noscript>

 

Is it because of the scope of the variables.

 

Thanks

Conversions script not triggering after form submission.

Top Contributor
# 5
Top Contributor

Hi Rajeev S.,

It's more the timing, I think. My function code would go on the original page. onSuccess() should call this function to record the conversion. It doesn't require loading conversion.js. If Javascript if disabled, a conversion won't be recorded. Then again, if Javascript is disabled, the user won't be able to submit the form.

I don't do jQuery much, so I don't know why your script doesn't work. If your code is wrapped in a function, the scope of the variables could be a problem. What might work is loading all the google_* variables on the global level when the form page originally loads. Then, have onSuccess() call jQuery.getScript() to record the conversion.

Best of Luck!

 

Pete

 

petebardo -- Deadhead doing AdWords