FAQs

How can I add Google Conversion tracking

Written
Google Conversion tracking needs to be placed after the form is submitted and can be done with a little code in a Custom Code action in the form On Submit event
Here is a code example; this assumes that the value to be recorded has been placed in the 'totalValue' in your form, edit this to match the input name you are using.
<?php
$track_value = $form->data['totalValue'];
/* Google Code for Purchase Conversion Page */
$doc =& JFactory::getDocument();
$doc->addScript('http://www.googleadservices.com/pagead/conversion.js');
$script = "
var google_conversion_id = 1234567890;
var google_conversion_language = 'en_US';
var google_conversion_format = '1';
var google_conversion_color = '666666';
if ( {$track_value} ) {
   var google_conversion_value = {$track_value};
}
var google_conversion_label = 'Purchase';
";
$doc->addScriptDeclaration($script);
echo "<noscript>
<img height=1 width=1 border=0 src='http://www.googleadservices.com/pagead/conversion/1234567890/?value={$track_value}&label=Purchase&script=0' />
</noscript>";
?>