1

提交 html 表单后,我需要记录一次 AdWords 转换。get_support.html 调用contact.php。这是代码的表单部分:

    <form method="post" action="contact.php">
    <div class="field">
        <label>WHAT DO YOU NEED HELP WITH?: <span>*</span></label>
        <textarea name="message" class="text textarea" ></textarea>
    </div>
    <div class="field">
        <label>NAME: <span>*</span></label>
        <input type="text" name="name" class="text" />
    </div>
    <div class="field">
        <label>PHONE NUMBER: <span>*</span></label>
        <input type="text" name="phone" class="text" />
    </div>

    <div class="field">
        <label>EMAIL: <span>*</span></label>
        <input type="text" name="email" class="text" />
    </div>

    <div class="field">
        <input type="button" id="send" value="SUBMIT INFO" />
        <div class="loading"></div>
    </div>

</form>

这是contact.php

    <?php
//Retrieve form data. 
//GET - user submitted data using AJAX
//POST - in case user does not support javascript, we'll use POST instead
$name = ($_GET['name']) ? $_GET['name'] : $_POST['name'];
$email = ($_GET['email']) ?$_GET['email'] : $_POST['email'];
$message = ($_GET['message']) ?$_GET['message'] : $_POST['message'];

//flag to indicate which method it uses. If POST set it to 1
if ($_POST) $post=1;

//Simple server side validation for POST data, of course, you should validate the email
if (!$name) $errors[count($errors)] = 'Please enter your telephone.';
if (!$email) $errors[count($errors)] = 'Please enter your email.'; 
if (!$message) $errors[count($errors)] = 'Please enter your message.'; 

//if the errors array is empty, send the mail
if (!$errors) {

    // ====== Your mail here  ====== //
    $to = 'US TECH SUPPORT <ustechsupport@techsupportheroes.com>';  
    //sender
    $from = $name . ' <' . $email . '>';

    //subject and the html message
    $subject = 'FORM-SUBMISSION-VIRUSREMOVALHEROES.COM';    
    $message = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head></head>
    <body>
    <table>
        <tr><td>Phone:</td><td>' . $name . '</td></tr>
        <tr><td>Email:</td><td>' . $email . '</td></tr>
        <tr><td>Message:</td><td>' . nl2br($message) . '</td></tr>
    </table>
    </body>
    </html>';

    //send the mail
    $result = sendmail($to, $subject, $message, $from);

    //if POST was used, display the message straight away
    if ($_POST) {
        if ($result) echo 'Help is on the way! We have received your message.';
        else echo 'Sorry, unexpected error. Please try again later';

    //else if GET was used, return the boolean value so that 
    //ajax script can react accordingly
    //1 means success, 0 means failed
    } else {
        echo $result;   
    }

//if the errors array has values
} else {}


//Simple mail function with HTML header
function sendmail($to, $subject, $message, $from) {
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
    $headers .= 'From: ' . $from . "\r\n";

    $result = mail($to,$subject,$message,$headers);

    if ($result) return 1;

    else return 0;  
}

?>

以及来自 Google 的用于我的表单填写的转换代码

echo '<!-- Google Code for Form Submission Conversion Page --> 
<script type="text/javascript"> 
/* <![CDATA[ */ 
var google_conversion_id = 1004137309; 
var google_conversion_language = "en"; 
var google_conversion_format = "3"; 
var google_conversion_color = "ffffff"; 
var google_conversion_label = "H1HvCNOWswQQ3dbn3gM"; 
var google_conversion_value = 0; 
/* ]]> */ 
</script> 
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js&amp;quot;&amp;gt; 
</script> 
<noscript> 
<div style="display:inline;"> 
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1004137309/?value=0&amp;amp;amp;label=H1HvCNOWswQQ3dbn3gM&amp;amp;amp;guid=ON&amp;amp;amp;script=0&amp;quot;/&amp;gt; 
</div> 
</noscript>'; 

我对此进行了研究,但无法弄清楚如何解决问题。任何帮助表示赞赏。

4

1 回答 1

0

Google Adwords 转换代码通过将转换跟踪代码放在“谢谢”页面上来工作。提交表单后,将用户引导至感谢页面。将您的转化跟踪代码放在此页面的源代码中,您将开始注册转化。由于用户访问此页面的唯一合乎逻辑的方式是提交一份填妥的联系表格。

此外,请确保除了提交表单(使用机器人并从现场所有其他页面取消链接)之外,没有其他方法可以访问此页面

于 2014-09-24T06:36:41.613 回答