Google Adwords conversion Tracking event - single page

I am very unfamiliar with all the google anaylytics / adwords / conversion etc ..

I have a client site ( wordpress ) , which is actually a single page , where it has a contact form at the bottom ( built with contact form 7 if one must know ).

The contact form is linked with an anchor ( # ) only. it is not a separate page.

The code for implementing is :

<!-- Google Code for Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
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 type="text/javascript" src="//">
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//;guid=ON&amp;script=0"/>

After reading a lot of questions here ( Like this ) , and also on the web, I have found some codes and hacked them into this :

<script type="text/javascript">
/* <![CDATA[ */
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 = ""+goalId+"/?random="+randomNum+"&value="+value+"&label="+label+"&guid=ON&script=0&url="+url;
img.src = trackUrl;
/* ]]> */

<script type="text/javascript" src="//">

My Questions are :

1 - The Tracking_conversion_custom() is invoked upon sending the form, but since I have a single page , will var url = encodeURI(location.href); work as expected as far as the google adwords tracking concern ? ( remember - it is an anchor only )

2 - In all the codes I have seen, the some vars are missing ( like var google_remarketing_only = false;, or google_conversion_format) - are they neglectable ? If not - how to add them ?

( Similar question here :Adding Google Conversion code to WordPress Contact Form 7 )


The encoded URL will be fine. Note that the label and goalID values will need to be the correct values from AdWords - label is now optional though so if one isn't provided in AdWords you'll need to remove it from this script (dont just pass garbage as that may lead to bad tracking)

However, this said if I were you rather than re-inventing the wheel and rolling my own code, I would just use the official Google tag that was designed specifically for this sort of usage:

That page explains what you need to do - it is coming from a remarketing perspective, but the conversion tag and the remarketing tag are basically the same thing (that is what the "google_remarketing_only" true/false is about - you'll want it to be "false" as this is conversion tracking).

So you'll want something like this, then just call google_trackConversion() whenever the form gets submitted - no messing about with encoding etc this way:

<!-- Put this script in your <head> -->
<script type="text/javascript" src="" charset="utf-8"></script>

<!-- the rest of your web page as usual etc -->

<!-- Call this function when the form submits -->
<script type="text/javascript">
/* <![CDATA[ */
  google_conversion_id: 123456789, 
  google_conversion_label: abcdefghijkl,  // if provided, remove this line if not provided
  google_conversion_value: 0,  // or the dollar value of this conversion, e.g. 100 etc.
  google_remarketing_only: false

Hope that helps.

Need Your Help

How to get rid of Checkstyle message 'File does not end with a newline.'

java windows maven-2 netbeans checkstyle

I'm working with a Maven (jar) Project in Netbeans (Windows), which creates Checkstyle reports with the Maven Checkstyle plugin.

UITableViewCell content flickers while reloading cells individually

ios objective-c performance uitableview asyncdisplaykit

I have a table view linked to a NSFetchedResultController (i.e. loading data and also tracking changes to data is bound to the FRC)