0

虽然对编码来说相对较新,但我之前已经成功实现了一些跟踪代码,但是在我的网站上注册一个转换代码时遇到了严重的问题。

虽然我已将其放入代码中 PHP 的相关部分,甚至进行了测试转换并在源代码中看到它,但 Google 未能注册单个转换,并且目标仍然显示为“未验证”。

我已经阅读了各种博客以及 Google 对在 PHP 中实现代码的看法——其中大多数似乎彼此不同意。如果有人有任何想法,我将不胜感激,因为它是跟踪我的 AdWords 效果的关键指标。

下面是谷歌给我的代码来实现原样:

<!-- Google Code for Almost there Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 974608389;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "d5KfCMunhgUQhbDd0AM";
var google_conversion_value = 0;
/* ]]> */
</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/974608389/?value=0&amp;label=d5KfCMunhgUQhbDd0AM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

现在,Google 希望您为 PHP 编辑代码的方式,在此处的部分下进行了详细说明: https: //support.google.com/adwords/answer/1722054?hl=en -GB

<!-- Google Code for Almost there Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 974608389;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "d5KfCMunhgUQhbDd0AM";
if (<%= totalValue %) {
    var google_conversion_value = <%= totalValue %>;
}
/* ]]> */
</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/974608389/?value=0&amp;label=d5KfCMunhgUQhbDd0AM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

我现在断断续续地浪费了大约 3 天的时间,并且花了足够长的时间来尝试点击广告并创建虚假帐户来对其进行测试以使其触发。

作为另一项保障措施,我也会在下面完整发布相关的 PHP 部分。

这是确认订阅付款的部分触发可能有助于查看您永远不会有太多信息,诊断问题。

<?php
/* Template Name: Subscription Confirmation */

  if (isset($_POST['activate_subscription']) && isset($_POST['token'])) {
    $activation = completeSubscription($_POST['token']);
    //completeSubscription Handles everything here. If this even runs, it's all gone wrong.
    $activate_failed = true;
  } else if (isset($_GET['token']) && isset($_GET['PayerID'])) {
    $transaction = getTransactionDetails($_GET['token']);
    if ($transaction['ACK'] == "Success") $sub = updateSubscriptionDetails($transaction);
  } else {
    header("Location: /join/membership/");
    exit();
  }



  get_header();
?>

<div class="row subhero">
  <div class="twelve columns">

    <?php if (!isset($activate_failed) && $transaction['ACK'] == "Success") { ?>

      <h1>Almost there!</h1>
      <p class="subheader">Thank you for configuring your subscription with PayPal.</p>
//***************** ANALYTICS CODE
<!-- Google Code for Subscription Conf Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 974608389;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "d5KfCMunhgUQhbDd0AM";
if (<%= totalValue %) {
    var google_conversion_value = <%= totalValue %>;
}
/* ]]> */
</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/974608389/?value=0&amp;label=d5KfCMunhgUQhbDd0AM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
//*********************END OF ANALYTICS CODE
  </div>
  </div>      
</div> <!-- end container -->
<div class="buyticketarea">
    <div class="row">
        <div class="eight columns offset-by-two">       


      <p class="subheader">Please confirm the following details. Once you proceed you will be billed immediately for your first month of <strong><?php echo $transaction['L_NAME0']; ?></strong> at <strong>&pound;<?php echo $transaction['L_AMT0']; ?>.</strong></p>
      <p class="subheader">Additionally, you will be billed <strong>&pound;<?php echo $transaction['L_AMT0']; ?></strong> on the <strong><?php echo date('j'); ?><sup><?php echo date('S'); ?></sup></strong> of each month, starting on <strong><?php echo getNextBillingDayHuman(); ?>.</strong></p>
      <p class="subheader">If you're happy to proceed...</p>
      <form method="post">
        <input type="hidden" name="sub_id" value="<?php echo $transaction['INVNUM']; ?>" />
        <input type="hidden" name="token" value="<?php echo $_GET['token']; ?>" />
        <input type="hidden" name="PayerID" value="<?php echo $_GET['PayerID']; ?>" />
        <input class="button" type="submit" name="activate_subscription" value="Activate Subscription" />
      </form>

    </div>
    </div>  
</div>
4

1 回答 1

0

这条线在我看来是错误的:

if (<%= totalValue %) {
    var google_conversion_value = <%= totalValue %>;
}

查看其他示例,它应该是:

if (<?php echo $totalValue ?>) {
    var google_conversion_value = <?php echo totalValue ?>;
}

但是,您没有设置价值,$totalValue所以也许所有转化都具有相同的价值?在这种情况下,您应该只使用:

var google_conversion_value = 10;
于 2013-07-04T14:38:48.480 回答