Contact Form 7 Google Adwords Conversions multiple forms
-
I’m going to start a new thread, since the other one is marked as resolved, and it’s not resolved (I hijacked a thread – sorry). I know next to nothing about JavaScript.
This is for Google Adwords, not Google Analytics, so the syntax of the tracking url is different. I do not want thank-you pages. I want to show a conversion in Adwords on successful submission.
I have a site with 4 or 5 different forms, each on their own page.
I’m just doing one form right now until I get it right.
Here’s the Google Adwords conversion code for the Contact page:
<!-- Google Code for Contact Conversion Page --> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = 1234567; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "alcqCKnt4wUQz8aqyQM"; 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/1234567/?value=0&label=alcqCKnt4wUQz8aqyQM&guid=ON&script=0"/> </div> </noscript>
On another thread it was suggested that I put all the functions for the different forms into one external js file, then call the js file in the header.php.
I’m using a child theme, so I’ve created a tracking.js file to put the functions for each form in and put that and a copy of the header.php form into the child theme folder.
At the bottom of the header.php in the child theme I’ve included:
<?php include 'tracking.js'; ?>
In the tracking.js file, I’ve put this code:
function Contact(){ var google_conversion_id = 959095631; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "alcqCKnt4wUQz8aqyQM"; var google_conversion_value = 0; var trackUrl = "//www.googleadservices.com/pagead/conversion/959095631/?value=0&label=alcqCKnt4wUQz8aqyQM&guid=ON&script=0" }
In the “Additional Settings” part of the Contact form, I’ve put in:
on_sent_ok: "Contact();"
And when I view the Contact page, I get this right below the navigation:
function Contact(){ var google_conversion_id = 1234567; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "alcqCKnt4wUQz8aqyQM"; var google_conversion_value = 0; var trackUrl = "//www.googleadservices.com/pagead/conversion/1234567/?value=0&label=alcqCKnt4wUQz8aqyQM&guid=ON&script=0" }
So I’ve done something wrong, and I don’t know enough JavaScript to tell what I’ve done wrong.
Can anyone shed some light on this, please? It’s making me crazed.
- The topic ‘Contact Form 7 Google Adwords Conversions multiple forms’ is closed to new replies.