Ecshop后台订单精准统计有助精准营销

显示IP,来源网站等信息,通过这些信息能帮助你更好的掌握潜在客户的来源与分布,为精准营销提供条件

修改文件:/languages/zh_cn/admin/common.php,添加如下代码:

  1. $_LANG['order_tongji'] = ’订单统计’;

修改文件:/admin/includes/inc_menu.php,添加

  1. /* 二次开发 订单统计 */

  2. $modules['06_stats']['order_tongji']              = ’order_tongji.php?act=list’;

创建文件:/admin/order_tongji.php

  1. <?php

  2. define(‘IN_ECS’, true);

  3. require(dirname(__FILE__) . ’/includes/init.php’);

  4. require(dirname(__FILE__) . ’/includes/cls_page.php’);

  5. /*—————————————————— */

  6. /*—————————————————— */

  7. if ($_REQUEST['act'] == ’list’)

  8. {

  9. $sql=urlencode(“SELECT * FROM ” .$ecs->table(‘tongji’).“ as t right join ” .$ecs->table(‘order_info’).“ as i on t.order_sn=i.order_sn order by tongji_id desc”);

  10. $pclass=new Page($sql,20,10,“”,“”,“”,“”);

  11. $pclass->SetPagePara(“par”,“paravalue”);

  12. $pclass->ShowList($_GET["startpage"],$_GET["t"],$_GET["offset"],“order_tongji.php”,“act=list”);

  13. $i=’1′;

  14. $html = ”;

  15. while($row=mysql_fetch_row($pclass->Result))

  16. {

  17. $html .= ’<tr>’;

  18. $html .= ’<td>’.$row[0].’</td>’;

  19. $html .= ’<td>’.$row[1].’</td>’;

  20. $html .= ’<td>’.$row[2].’</td>’;

  21. $html .= ’<td>’.date(‘Y-m-d H:i:s’,$row[4]+28800).’</td>’;

  22. $html .= ’<td>’.$row[6].’</td>’;

  23. $html .= ’<td>’.$row[5].’</td>’;

  24. $html .= ’<td>’.$row[7].’</td>’;

  25. $html .= ’<td>’.$row[8].’</td>’;

  26. $html .= ’</tr>’;

  27. }

  28. $smarty->assign(‘page’, $pclass->OutPut);

  29. $smarty->assign(‘content’, $html);

  30. $smarty->display(‘tongji.htm’);

  31. }

  32. ?>

创建文件:/admin/templates/tongji.htm

  1. {include file=“pageheader.htm”}

  2. <div class=“list-div” id=“listDiv”>

  3. <table width=“100%” border=“0″ cellpadding=“3″ cellspacing=“1″>

  4. <tr>

  5. <th>编号</th>

  6. <th>订单号</th>

  7. <th>收货人</th>

  8. <th>下单时间</th>

  9. <th>ip</th>

  10. <th>来源网站</th>

  11. <th>来源URL</th>

  12. <th>受访URL</th>

  13. </tr>

  14. {$content}

  15. <tr><td colspan=“8″ align=“center”><BR>{$page}</td></tr>

  16. </table>

  17. </div>

  18. {include file=“pagefooter.htm”}

修改文件 /flow.php 1246行左右,添加如下代码

  1. if(isset($_COOKIE['request_info'])){

  2. $request_info = unserialize(strtr($_COOKIE['request_info'],array(“\”=>”“)));

  3. $sql = ”INSERT INTO “.$ecs->table(‘tongji’).”(order_sn, user_name,start_time,end_time,host,ip,start_url,end_url) value(‘“.$order['order_sn'].”‘,’“.$order['c**ignee'].”‘,’“.$request_info['time'].”‘,’“.gmtime().”‘,’“.$request_info['host'].”‘,’“.$_SERVER['REMOTE_ADDR'].”‘,’“.$request_info['start_url'].”‘,’“.$request_info['end_url'].”‘)“;

  4. }else{

  5. $sql = ”INSERT INTO “.$ecs->table(‘tongji’).”(order_sn, user_name,start_time,end_time,host,ip,start_url,end_url) value(‘“.$order['order_sn'].”‘,’“.$order['c**ignee'].”‘,’“.gmtime().”‘,’“.gmtime().”‘,’本站’,’“.$_SERVER['REMOTE_ADDR'].”‘,’本站’,'本站’)”;

  6. }

  7. $db->query($sql);

修改文件 include/init.php,添加

  1. /* 记录请求信息 */

  2. function request_info(){

  3. $start_url = $_SERVER['HTTP_REFERER']; //来源网站

  4. $start_url_info = parse_url($start_url);

  5. if($start_url_info['host']!=$_SERVER['SERVER_NAME'] && $start_url_info['host']!=”){

  6. $request_info = array();

  7. $request_info['host'] = $start_url_info['host']; //域名

  8. $request_info['time'] = gmtime(); //时间

  9. $request_info['start_url'] = $start_url; //时间

  10. $request_info['end_url'] = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; //被访页面

  11. setcookie(‘request_info’, serialize($request_info), time()+86400, “/”);

  12. }

  13. }

  14. request_info();

(0)

相关推荐