Zencart 对接 Afilter Tracker

本篇文章讲教会你如何使用 Afilter Tracker 追踪 Zencart的推广数据

通常,电商广告在第三方联盟的推广形式为CPS/CPA,委托联盟去接洽站长等第三方营销人员,比如说在CJ联盟投放广告。但您也可以选择自己去流量源直接购买流量,这个时候您可以通过 Afilter Tracker 直接追踪并优化您的广告效果,增加回报率。

安装访客操作追踪脚本

想要追踪效果的前提,就是需要在全部页面安装一个访客追踪脚本。追踪脚本支持追踪以下事件:

搜索产品 / event_6
产品分类页浏览 / event_7
产品详情页浏览 / event_8
添加产品到购物车 / event_9
注册账户 / event_10
完成购买 / postback
访客30s存活数 / event_4
访客60s存活数 / even_5

<script src="https://afilter.xyz/js/zencart.js"></script>

配置效果回传

修改 includes/templates/template_default/templates/tpl_checkout_success_default.php 文件
如果您模版有自定义修改,则将 template_default 替换为您模版的目录。

找到该行:

<div id="checkoutSuccessOrderNumber"><?php echo TEXT_YOUR_ORDER_NUMBER . $zv_orders_id; ?></div>

使用以下代码替换:

<div id="checkoutSuccessOrderNumber"><?php echo TEXT_YOUR_ORDER_NUMBER . $zv_orders_id; ?></div>

<?php
    $dbreq = $db->Execute("select * from ".TABLE_ORDERS_TOTAL." where orders_id = '".(int)$orders->fields['orders_id']."' AND class in ('ot_coupon', 'ot_gv', 'ot_subtotal', 'ot_group_pricing', 'ot_quantity_discount')");
    while (!$dbreq->EOF) {
        switch ($dbreq->fields['class']) {
            case 'ot_subtotal': $order_subtotal = $dbreq->fields['value']; break;
            case 'ot_coupon': $coupon_amount = $dbreq->fields['value']; $coupon_code = $dbreq->fields['title']; break;
            case 'ot_group_pricing': $group_pricing_amount = $dbreq->fields['value']; break;
            case 'ot_gv': $gv_amount = $dbreq->fields['value']; break;
            case 'ot_quantity_discount': $quantity_discount_amount = $dbreq->fields['value']; break;
        }
        $dbreq->MoveNext();
    }
    $totalCost = ($order_subtotal - $gv_amount - $coupon_amount - $group_pricing_amount - $quantity_discount_amount);
    $totalCost = number_format($totalCost,2,'.','');
    $orderId = $dbreq->fields['orders_id'];

    // ------------- coupon code --------------------------------------------------
    $coupon_code = substr($coupon_code,(strpos($coupon_code,":"))+2);
    $coupon_code = substr($coupon_code,0,strlen($coupon_code)-2);

    // -------------products---------------------------------------------------------
    $productId = "";
    $dbreqa = $db->Execute("select products_id from ".TABLE_ORDERS_PRODUCTS." where orders_id = '".(int)$orders->fields['orders_id']."' ");
    while (!$dbreqa->EOF) {
        $productId = $dbreqa->fields['products_id'];
        $dbreqa->MoveNext();
    }
    // ----------end products--------------------------------------------------------
    print '<img style="display:none;" width="1" height="1" src="https://afilter.xyz/p?txid='.$orderId.'&currency=USD&payout='.$totalCost.'&t='.time().'">';
?>

同时,您可能需要将倒数第二行的 currency=USD 替换为您当前的货币种类。我们会自动将结算金额转换为美元。