I am very unfamiliar with all google anaylytics / adwords / conversion etc.
I have a client site (wordpress), which is actually one page where it has a contact form below (built using contact form 7, if you need to know).
The contact form is associated only with the anchor ( # ). This is not a separate page.
Code for implementation:
<script type="text/javascript"> var google_conversion_id = 010101010101; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "SomeRandomLabel"; 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="//www.googleadservices.com/pagead/conversion/971631980/?label=MCwlCLTErgoQ7NqnzwM&guid=ON&script=0"/> </div> </noscript>
After reading a lot of questions here (like this), as well as on the Internet, I found several codes and hacked them into this:
<script type="text/javascript"> function Tracking_conversion_custom(){ var img = document.createElement("img"); var goalId = 010101010101; var randomNum = new Date().getMilliseconds(); var value = 0; var label = "SomeRandomLabel"; var url = encodeURI(location.href); var trackUrl = "http://www.googleadservices.com/pagead/conversion/"+goalId+"/?random="+randomNum+"&value="+value+"&label="+label+"&guid=ON&script=0&url="+url; img.src = trackUrl; document.body.appendChild(img); } </script> <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> </script>
My questions:
1 - When submitting the form, Tracking_conversion_custom() is called, but since I have one page, will var url = encodeURI(location.href); work as expected regarding Google AdWords tracking? (remember - this is just a binding)
2 - In all the codes that I saw, some vars are missing (for example, var google_remarketing_only = false; or google_conversion_format ) - are they negligible? If not, how to add them?
(A similar question here: Adding Google Conversion code to a WordPress 7 contact form )
source share