Forums

How to add Google Code

Sjorzzzie 12 Oct, 2009
Hi, I have to add a Google Code Conversion Page.
It's a JavaScript code wich has to be added just before the </body> tag, on the "thank you" page, on multiple forms wich i made.

<!-- Google Code for Purchase Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 1234567890;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "666666";
var google_conversion_label = "Purchase";
//-->
if (<? echo $totalValue ?>) {
var google_conversion_value = <? echo $totalValue ?>
}
</script>
<script language="JavaScript"
src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0
src="http://www.googleadservices.com/pagead/conversion/1234567890/?value=<? echo
$totalValue ?>&label=Purchase&script=0">
</noscript>

Who knows where i should place this code on a Form?
GreyHead 26 Oct, 2009
Hi Sjorzzzie,

You can put this code into the OnSubmit After box - make it the last code at the end it won't be too far off the end of the page.

Bob
zest96 24 Jan, 2010
Hi Bob,

I couldn't find any information of where and how to put the google adwords code for the "thank you" page. I believe I don't really need to see the code on the source of the thank you page since I don't paste it there ( and can't paste there). So I guess pasting it somehow on the "onSubmit" box would run it right after the form is submitted...
But I'm not sure what is the syntax...
the code looks like this:
<!-- Start Google AdWords Code for Socialwork.tau.ac.il-overseas LEAD Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = 1024837455;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "dagQCKXjvQEQz47X6AM";
var google_conversion_value = 0;
if (150) {
  google_conversion_value = 150;
}
//-->
</script>
<script type="text/javascript" src="http://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/1024837455/?value=150&label=dagQCKXjvQEQz47X6AM&guid=ON&script=0"/>
</div>
</noscript>
<!-- END Google AdWords Code for Socialwork.tau.ac.il-overseas LEAD Conversion Page -->
GreyHead 26 Jan, 2010
Hi zest96,

Just the same as my previous post. Paste the code into the OnSubmit After box.

Bob
zest96 26 Jan, 2010
Hi Bob, I've found a better solution.
due to the fact that the form is displayed as a module in some pages, the presence of the googleAd code might submit hits on the contact form.

the solution is neat. I've created two modules: one for the contact page and the other for the thank you page.

I've {loadposition GoogleBeforeSubmit} for a contact page (article) with {chronocontact}formname{/cronocontact}

and {loadposition GoogleAfterSubmit} to the thankyou page ( also article)

this solution works perfect and sends accurate data to analytics while the form does not holds any googleAd codes.

thanks again Bob, hope this will help somebody.
I can explain in more details if needed.
ericbecky 03 Sep, 2010
I put the code in the "On Submit code - after sending email:" section.

But I get this error:

Parse error: syntax error, unexpected T_STRING in/home2/greendri/public_html/components/com_chronocontact/libraries/chronoform.php(258) : eval()'d code on line4



Any idea why this comes up?

This was the code I had in the "On Submit code - after sending email:" section.:

<?php
$doc =& JFactory::getDocument();
$script ="var google_conversion_id = xxxxxxxxxxx;
var google_conversion_language = 'en_US';
var google_conversion_format = '1';
var google_conversion_color = 'ffffff';
var google_conversion_label = 'yyyyyyyyyyyyyyyyyyyyyyy';
";
$doc->addScriptDeclaration($script);
$doc->addScript("http://www.googleadservices.com/pagead/conversion.js");
?>
<noscript>
<img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/xxxxxxxxxxx/?label=yyyyyyyyyyyyyyyyyyyyyyy&guid=ON&script=0"/>
</noscript>
alt="Coupon for the site" title="Coupon for the site" width="725" height="250"</p>
<p>This is the discount code you used: {code}</p>
<p>This coupon is good for {regnumber} admission(s) for Green Drive Expo - Bay Area</p>
<p>Your coupon will also be emailed to you at: {email}</p>
<p><strong>Please be sure to print your coupon and bring it with you on October 9th</strong></p>

<a href="http://www.facebook.com/pages/Green-Drive-Expo/xxxxxxxxxxxxxxxxx" target="_blank"><img src="images/stories/BayArea/facebook.png" border="0" alt="Green Drive Expo Bay Area on facebook." title="GDE Bay Area on facebook"/></a> . . .
<a href="http://twitter.com/GreenDriveExpo" target="_blank"><img src="images/stories/BayArea/twitter.png" border="0" alt="Green Drive Expo Bay Area on twitter." title="GDE Bay Area on twitter"/></p>
<form> <input onclick="window.print()" type="button" value="Print This Page" /> </form>




I had also tried this code for the first part, but got the same error

<!-- Google Code for register Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxxxxxxxxx;
var google_conversion_language = "en";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "yyyyyyyyyyyyyyyyyyyyyyy";
var google_conversion_value = 0;
/* ]]> */
</script>
<script type="text/javascript" src="http://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/xxxxxxxxxxx/?label=yyyyyyyyyyyyyyyyyyyyyyy&guid=ON&script=0"/>
</div>
</noscript>

GreyHead 03 Sep, 2010
Hi ericbecky ,

The error appears to be in the Server-side validation box? What code do you have in there?

Bob
ericbecky 03 Sep, 2010
As always... you are correct.

We had added some code in the server side validation box that made sure that the text entered in the "Discount Code" text box matched a real coupon code that we have in a list in a separate table.

Well somehow a bit of script had slipped in with the rest of the validation code and it messed things up. (bolded below.)

It was absolutely nothing to do with a problem from ChronoForms or the formation of the adwords code.

I still have to have my adwords guy verify everything else is working right, but I know for sure that the original parse error is gone.

Thanks for pointing me in the right direction.
Just wondering... what cued you into the fact that the error was in the validation code?

Validation Code box

<?php
$db =& JFactory::getDBO();
$id=JRequest::getString('code');
$id=strtolowe<script type="text/javascript" src="http://www.greendriveexpo.com/administrator/components/com_chronocontact/js/tiny_mce/themes/advanced/langs/en.js">
</script>
r ($id);
$id=$db->getEscaped( $id );
$query = "SELECT * FROM #__jvredirect where name='".$id."'";
$db->setQuery( $query);
$row = $db->loadObjectList();
if ($db->getErrorNum()||count($row)==0) {

return 'That is not a valid Discount Code. Please check your code and enter it again.' ;
}

?>

GreyHead 03 Sep, 2010
Hi ericbecky,

Well that is a ChronoForms link but it certainly doesn't belong in there.

The clue is in the error message

com_chronocontact/libraries/chronoform.php(258) : eval()'d code on line4


That's line 258 of the chronoform.php file (and line 4 of the evaluated code). I opened the file up to see what was in line 258 et voila !

Bob
ericbecky 03 Sep, 2010
Thanks again.

o.k. to go a little off topic here, is it possible that the rogue chronoforms link was "dragged and dropped" from somewhere else on the page? (And what is that link anyway?) The reason I ask is because I think I've seen that same bit of link mysteriously showing up elsewhere.

I have a new laptop and sometime I select things when I don't mean to as I use the touchpad so it is probably something I did without even realizing it. I'm watching it more closely though.
GreyHead 03 Sep, 2010
Hi ericbecky,

I guess it's possible but ought to be unlikely. We have seen odd random sproutings of script snippets from the tiny_mce files that have never been explained.

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