Patrick Ryan
Patrick Ryan

Reputation: 53

How can I track AdWords conversions using Javascript?

I need to execute Google AdWords conversion code but I have constraints...

Here are the given circumstances:

1) I cannot redirect to another page to allow the conversion code to run. (client request)

2) I cannot add an onClick function to my submit button because it is not directly editable. (plugin restraint, I'm using a WordPress plugin called "Easy Contact Forms")

How do I turn this AdWords code into an executable Javascript chunk that will function when a user clicks submit on the form:

<!-- Google Code for sent email Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "XXXXXXXXXXXXXXXXXXX";
var google_conversion_value = 0;
/* ]]> */
</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="//www.googleadservices.com/pagead/conversion/XXXXXXXXX/?value=0&amp;label=XXXXXXXXXXXXXXXXX&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

And here is the chunk of code that contains the form area that includes the submit button:

<span id="ufo-field-id-630-span">
<noscript><button type='submit' id='ufo-field-id-630' name='id-630' >Send Message</button></noscript>
<button class="" type="button" style="">Send Message</button>
</span>

Now remember I am not able to edit this area of the plugin because of the way the plugin is coded. Any help would be greatly appreciated.

I also want to forewarn you that I know very little about JavaScript so if possible could you please go easy on me with a solution?

Thanks in advance! Patrick

Upvotes: 0

Views: 502

Answers (1)

Roman Rybalchenko
Roman Rybalchenko

Reputation: 21

Look my answer here How to execute Google Adwords conversion tracking without physical thank you page, in another stackoverflow discussion. It looks like, that it is the same question as yours.

Upvotes: 1

Related Questions