Forums

Google conversion tracking

GreyHead 11 Jul, 2014
Hi karbon,

The code there should still work OK with ChronoForms v5 and Joomla! 3; it may be that Google has changed the specification for recording tracking.

Do you see any JavaScript errors on the page?

Bob
karbon 11 Jul, 2014
Hi.
I have no js error on the confirmation page, but I don't see my tracking code in source, too.
This is the google code tracking :

<!-- Google Code for form contact EL Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = ABCD;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "123456";
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/ABCD/?label=123456&guid=ON&script=0"/>
</div>
</noscript>


and this is what I've do :
in setup, On Sumit / Recaptcha / On Success, i've insert this custom code :
<?php
/* Google Code for form contact EL Conversion Page */
$doc =& JFactory::getDocument();
$doc->addScript('http://www.googleadservices.com/pagead/conversion.js');
$script = "
var google_conversion_id = ABCD;
var google_conversion_language = 'en';
var google_conversion_format = '3';
var google_conversion_color = 'ffffff';
var google_remarketing_only = false;
var google_conversion_label = '123456';
";
$doc->addScriptDeclaration($script);
echo "<noscript><div style='display:inline;'><img height='1' width='1' style='border-style:none;' alt='' src='http://www.googleadservices.com/pagead/conversion/ABCD/?&label=123456&guid=ON&script=0' /></div></noscript>";
?>


Maybe my code is wrong ?
Thanks for your help.
GreyHead 11 Jul, 2014
Hi karbon,

Please post a link to the form so I can take a quick look.

NB: I recommend that you don't use the On Success events in general. Put actions that need to follow 'success' in the main on Submit event. It just keeps your forms tidier.

Bob
karbon 11 Jul, 2014
I've tried to put my code in On Submit event.
In my confirmation page source I don't see the tracking.

I've put another tracking in On Load event and this one is visible in the form page source, before submission.
I think this one will work.
Put problem is for the On Submit tracking.

I give you URL in PM
thanks
GreyHead 11 Jul, 2014
Hi karbon,

It looks to me as though the problem is one of timing. Because the conversion.js file and the JavaScript 'snippet' are being loaded by Joomla! the snippet loads after the conversion.js file so the values aren't available :-(

Please try this version and see if that works:
<?php
$doc = JFactory::getDocument();
$script = "
var google_conversion_id = ABCD;
var google_conversion_language = 'en';
var google_conversion_format = '3';
var google_conversion_color = 'ffffff';
var google_remarketing_only = false;
var google_conversion_label = '123456';
";
$doc->addScriptDeclaration($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='http://www.googleadservices.com/pagead/conversion/ABCD/?&label=123456&guid=ON&script=0' /></div></noscript>

Bob
karbon 11 Jul, 2014
ok, I try.
but first line is $doc = JFactory::getDocument();
not $doc =& JFactory::getDocument();
?
GreyHead 12 Jul, 2014
Hi karbon,

The & is deprecated in PHP 5.3 (or is it 5.4) and may show a PHP warning message if it is included if you are using Joomla! 3

Bob
karbon 16 Jul, 2014
ok
in all case, I don't see the google conversion code in the validation form page.
with or without &
GreyHead 16 Jul, 2014
Hi karbon,

Exactly what code have you added and where have you put it?

Bob
karbon 16 Jul, 2014
Hi GreyHead
My code is in On Submit section, Custom Code.
exactly this one :
<?php
$doc = JFactory::getDocument();
$script = "
var google_conversion_id = 1041232637;
var google_conversion_language = 'en';
var google_conversion_format = '3';
var google_conversion_color = 'ffffff';
var google_remarketing_only = false;
var google_conversion_label = 'CuFgCLP4uAkQ_eW_8AM';
";
$doc->addScriptDeclaration($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='http://www.googleadservices.com/pagead/conversion/1041232637/?&label=CuFgCLP4uAkQ_eW_8AM&guid=ON&script=0' /></div></noscript>

Thanks
This topic is locked and no more replies can be posted.