CAP_TBP
02-27-2009, 10:14 AM
We had our form completed by a company that no longer supports Perl and I need to get my form updated with the Google Adwords Conversion Tracking Code. I followed the directions provided by Google, but they aren't helpful since the form is in Perl. Below, I will post the code to be added and my form. Can anyone assist me with how to include the code? Thank you.
The Google Adwords Conversion Tracking Code that needs to be entered into my Perl form is:
<!-- Google Code for TBI Programs Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 1071331077;
var google_conversion_language = "en_US";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "X8IuCPecZxCF7uz-Aw";
//-->
</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/1071331077/?label=X8IuCP
ecZxCF7uz-Aw&guid=ON&script=0"/>
</noscript>
My Form Code is:
#!c:/perl/bin/Perl.exe
##
## emailFormData.pl -- Sends form data to email recipient(s) listed in hidden
form field emailto
## Expects to
receive two form params: formname, emailto
## formname
- self explanatory, the name of the form
## emailto
- a comma separated list of email addresses
##
can be as little as one or multiple email addresses
##
examples:
##
SomeEmail@somedomain
##
SomeEmail@somedomain.com,SomeEmail@somedomain.com
##
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Net::SMTP;
my $query = new CGI;
my $formname = param('formname');
my $emailfrom = param('emailfrom');
my $emailto = param('emailto');
my $emailsubject = param('emailsubject');
my $print_debug_info = 'no';
my $sendEmail = 'yes';
my $error_message = '';
my $error = 0;
my ($var, $name, $value, $val);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = $year + 1900;
$mon = $mon + 1;
my $today_date = $mon.'/'.$mday.'/'.$year;
my $ampm = ' am';
if ($hour > 12) {
$hour = $hour - 12;
$ampm = ' pm';
}
my $today_time;
if ($min < 10) {
$today_time = $hour.':0'.$min.$ampm;
} else {
$today_time = $hour.':'.$min.$ampm;
}
my @keywords = $query->keywords;
my @names = $query->param;
print $query->header(-expires=>'now');
print $query->start_html(-title=>'Email Form Data');
my $emailText = '';
my $displayText = '<b>requestor_IP : </b>'.$ENV{'REMOTE_ADDR'}.'<br>'.
'<b>script_name :
</b>'.$ENV{SCRIPT_NAME}.'<br>';
my $kntr = 0;
foreach my $name (@names) {
if ( lc($name) ne 'submit' ) {
if ( lc(param($name)) eq 'checkbox') {
$emailText .= $name.': CHECKED'."\n";
$displayText .= '<b>'.$name.'</b>:
'.param($name).'<br>';
} else {
$emailText .= $name.': '.param($name)."\n";
$displayText .= '<b>'.$name.'</b>:
'.param($name).'<br>';
}
}
$kntr++;
}
$emailText =~ s/_/ /g; ## Replace underscores with spaces
$displayText =~ s/_/ /g; ## Replace underscores with spaces
$emailText =~ s/checkbox/Yes/g; ## Replace word checkbox with Yes
$displayText =~ s/checkbox/Yes/g; ## Replace word checkbox with Yes
if ( $print_debug_info eq 'yes' ) {
print $query->Dump;
print '<h4>'.$displayText.'</h4>';
}
my @distList = split(",", $emailto );
if ( $sendEmail eq 'yes' ) {
foreach my $sendTo ( @distList ) {
#print "<h4> email sent to $sendTo".'</h4>';
Send_Email($emailfrom, $sendTo, $emailsubject, $emailText);
}
print qq!<h4>
Thank you.<br>
Your request has been submitted and a
Teambuildinginc.com
consultant will contact you within 2 business
days to provide you with a proposal based on your situation and needs. <br>
To return to the Teambuildinginc.com site: <a
href="http://www.teambuildinginc.com">Click Here</a> </h4>!;
}
print $query->end_html;
exit;
###########################################
sub Send_Email() {
my ($MailFrom, $MailTo, $Subject, $Body, $ServerName) = ( @_ );
my $testonly = 1;
if ($MailFrom eq '') { $MailFrom = 'inquire@teambuildinginc.com'; }
if ($MailTo eq '') { $MailTo = 'inquire@teambuildinginc.com'; }
if ($Subject eq '') { $Subject = "Subject"; }
if ($Body eq '') { $Body = "Body"; }
if ($testonly == 1) {
$Subject = $Subject;
}
if ($ServerName eq '') { $ServerName = "localhost"; }
# Create a new SMTP object
my $smtp = Net::SMTP->new($ServerName);
# If you can't connect, don't proceed with the rest of the script
die "Couldn't connect to server" unless $smtp;
$smtp->mail( $MailFrom );
$smtp->to( $MailTo );
$smtp->data();
# Send the header
# This address will appear in the message
$smtp->datasend('To: '.$MailTo."\n");
# So will this one
$smtp->datasend('From: '.$MailFrom."\n");
$smtp->datasend("Subject: $Subject\n");
$smtp->datasend("\n");
# Send the Body.
$smtp->datasend("$Body\n\n");
# Send the termination string
$smtp->dataend();
# Close the connection
$smtp->quit();
}
The Google Adwords Conversion Tracking Code that needs to be entered into my Perl form is:
<!-- Google Code for TBI Programs Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 1071331077;
var google_conversion_language = "en_US";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "X8IuCPecZxCF7uz-Aw";
//-->
</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/1071331077/?label=X8IuCP
ecZxCF7uz-Aw&guid=ON&script=0"/>
</noscript>
My Form Code is:
#!c:/perl/bin/Perl.exe
##
## emailFormData.pl -- Sends form data to email recipient(s) listed in hidden
form field emailto
## Expects to
receive two form params: formname, emailto
## formname
- self explanatory, the name of the form
## emailto
- a comma separated list of email addresses
##
can be as little as one or multiple email addresses
##
examples:
##
SomeEmail@somedomain
##
SomeEmail@somedomain.com,SomeEmail@somedomain.com
##
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Net::SMTP;
my $query = new CGI;
my $formname = param('formname');
my $emailfrom = param('emailfrom');
my $emailto = param('emailto');
my $emailsubject = param('emailsubject');
my $print_debug_info = 'no';
my $sendEmail = 'yes';
my $error_message = '';
my $error = 0;
my ($var, $name, $value, $val);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = $year + 1900;
$mon = $mon + 1;
my $today_date = $mon.'/'.$mday.'/'.$year;
my $ampm = ' am';
if ($hour > 12) {
$hour = $hour - 12;
$ampm = ' pm';
}
my $today_time;
if ($min < 10) {
$today_time = $hour.':0'.$min.$ampm;
} else {
$today_time = $hour.':'.$min.$ampm;
}
my @keywords = $query->keywords;
my @names = $query->param;
print $query->header(-expires=>'now');
print $query->start_html(-title=>'Email Form Data');
my $emailText = '';
my $displayText = '<b>requestor_IP : </b>'.$ENV{'REMOTE_ADDR'}.'<br>'.
'<b>script_name :
</b>'.$ENV{SCRIPT_NAME}.'<br>';
my $kntr = 0;
foreach my $name (@names) {
if ( lc($name) ne 'submit' ) {
if ( lc(param($name)) eq 'checkbox') {
$emailText .= $name.': CHECKED'."\n";
$displayText .= '<b>'.$name.'</b>:
'.param($name).'<br>';
} else {
$emailText .= $name.': '.param($name)."\n";
$displayText .= '<b>'.$name.'</b>:
'.param($name).'<br>';
}
}
$kntr++;
}
$emailText =~ s/_/ /g; ## Replace underscores with spaces
$displayText =~ s/_/ /g; ## Replace underscores with spaces
$emailText =~ s/checkbox/Yes/g; ## Replace word checkbox with Yes
$displayText =~ s/checkbox/Yes/g; ## Replace word checkbox with Yes
if ( $print_debug_info eq 'yes' ) {
print $query->Dump;
print '<h4>'.$displayText.'</h4>';
}
my @distList = split(",", $emailto );
if ( $sendEmail eq 'yes' ) {
foreach my $sendTo ( @distList ) {
#print "<h4> email sent to $sendTo".'</h4>';
Send_Email($emailfrom, $sendTo, $emailsubject, $emailText);
}
print qq!<h4>
Thank you.<br>
Your request has been submitted and a
Teambuildinginc.com
consultant will contact you within 2 business
days to provide you with a proposal based on your situation and needs. <br>
To return to the Teambuildinginc.com site: <a
href="http://www.teambuildinginc.com">Click Here</a> </h4>!;
}
print $query->end_html;
exit;
###########################################
sub Send_Email() {
my ($MailFrom, $MailTo, $Subject, $Body, $ServerName) = ( @_ );
my $testonly = 1;
if ($MailFrom eq '') { $MailFrom = 'inquire@teambuildinginc.com'; }
if ($MailTo eq '') { $MailTo = 'inquire@teambuildinginc.com'; }
if ($Subject eq '') { $Subject = "Subject"; }
if ($Body eq '') { $Body = "Body"; }
if ($testonly == 1) {
$Subject = $Subject;
}
if ($ServerName eq '') { $ServerName = "localhost"; }
# Create a new SMTP object
my $smtp = Net::SMTP->new($ServerName);
# If you can't connect, don't proceed with the rest of the script
die "Couldn't connect to server" unless $smtp;
$smtp->mail( $MailFrom );
$smtp->to( $MailTo );
$smtp->data();
# Send the header
# This address will appear in the message
$smtp->datasend('To: '.$MailTo."\n");
# So will this one
$smtp->datasend('From: '.$MailFrom."\n");
$smtp->datasend("Subject: $Subject\n");
$smtp->datasend("\n");
# Send the Body.
$smtp->datasend("$Body\n\n");
# Send the termination string
$smtp->dataend();
# Close the connection
$smtp->quit();
}