Google Conversion Tracking in OnSubmit doesn't work

How to fix Google Conversion Tracking not working in ChronoForms.

Overview

The issue occurs when PHP tags are incorrectly included around JavaScript code in the OnSubmit custom code action, causing a parse error.
Remove the opening and closing PHP tags from the custom code action, ensuring only the JavaScript tracking code remains. For other placements, use a Custom Code or Display Message action with plain text settings and verify there are no JavaScript errors on the page.

Answered
an analographi 06 Mar, 2015
Answer
Hi

In the "Onsubmit" "custom code" I have the following code:

<?php
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1047843479;
var google_conversion_language = "de";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "2XniCKjFkVoQl6XT8wM";
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/1047843479/?label=2XniCKjFkVoQl6XT8wM&guid=ON&script=0"/>
</div>
</noscript>
?>


I get this error on submit:
Parse error: syntax error, unexpected '<' in /home/subconsc/public_html/tentickle/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(18) : eval()'d code on line 2


Any ideas?
an analographi 06 Mar, 2015
I did check that before I started, and it doesn't help.
good job though, bot😉
Max_admin Max_admin 06 Mar, 2015
1 Likes
Please remove the php tags:

<?php
and at the end:
?>

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
oz ozi 12 Jun, 2015
My Google tracking code doesn't seem to work either. I've searched on this forum and followed the instructions. but it doesn't work. I've put a picture of the place where I've put the Google tracking code. Its in the 'Load JavaScript' section.

Anyone a idea how I can fix this?

Oz
Gr GreyHead 12 Jun, 2015
Hi ozii,

Please use your browser web developer tools to check for javascript errors on the thank you page.

Bob
oz ozi 06 Jul, 2015
Hi,

Doesn't seem to work still. I'm not sure but can you put the google code in the 'Display message' block after the text section?
Maybe then it works? any idea?

Greetings from

Oz
Gr GreyHead 07 Jul, 2015
Hi Ozi,

Did you check for JavaScript errors?

I think that the code will work in a Display Message action (provided that you have no PHP and use the plain text settings, not the Rich Text editor), or better a Custom Code action.

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