0

我有一个 PHP 表单,它在提交时将表单数据发送到邮件(),然后如果成功将它们返回到引用页面(换句话说,将它们与表单保持在同一页面上)并将 ?success=TRUE 附加到 URL。

问题是,我将如何实现 AdWords 和 Yahoo Search Marketing 转换代码段以仅在提交表单时触发?出于功能目的,不幸的是,在提交时将它们发送到另一个页面是不可行的,这本来是最简单的方法。

发送结果并将其发送回主页的表单提交操作的相关代码如下。我有一种预感,它可能就像在最后的 if 语句中输出转换跟踪代码片段一样简单,但我不确定这是否正确或正确执行此操作的语法。

if ( isset($_POST['sendContactEmail']) )
    {

$fname = $_POST['posFName'];
$lname = $_POST['posLName'];
$phone = $_POST['posPhone'];
$email = $_POST['posEmail'];
$note = $_POST['posText'];

$to = $yourEmail;
$subject = $yourSubject;

$message = "From: $fname $lname\n\n Phone: $phone\n\n Email: $email\n\n Note: $note";

$headers = "From: ".cleanPosUrl($_POST['posFName']. " " .$_POST['posLName'])." \r\n";

$headers .= 'To: '.$yourName.' '."\r\n";

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

if ( @$mailit ) {
        header('Location: '.$referringPage.'?success=true');
        }

else {
        header('Location: '.$referringPage.'?error=true');
        }
    }
4

1 回答 1

0

Outputting it in the if-Statement would be a possibility, but the script you posted adds another way to do it as it redirects to the $referringPage - if the mail was successfully sent. And that's the only event you want to track a conversion.

So edit the code of $referringPage (the page that holds the form fields) and add:

<?php
if($_GET['success'] == 'true') {
    echo "...";
}
?>

"..." ofcourse has to be replaced by the Adwords conversion Code Google gave you. If you add it to your question, I could even add it to my answer.

于 2010-01-18T22:00:20.447 回答