成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

js追蹤腳本

js 追蹤腳本
lk_t.js
var LK = {
  version:"1.0",
  host:"",
  key:"LK",
  expire_days:3600,
  cmds:[],
  tracker:function()
  {
    var that = this.tracker;
    that.timestamp = this.getTimestamp();
    that.prop = {};
    //發(fā)送請求
    that.log = function (param){
      var img = new Image(1, 1);
      img.onLoad = function (){};
      img. LK.buildUrl(param);
    };
  },
  //處理命令隊列
  submit:function()
  {
    this.tracker();
    for(var i in this.cmds)
    {
      line = this.cmds[i];
       //call和apply,它們的作用都是將函數(shù)綁定到另外一個對象上去運行
      //Array.prototype.slice這句就是訪問Array的內置方法
      var args = Array.prototype.slice.call(line, 1);
      if(!window[this.key])
        window[this.key] = this;
      window[this.key][line[0]].apply(this.tracker, args);
    }
  },
  setSiteId:function(siteid)
  {
    this.siteid = siteid;
  },
  //跟蹤PV
  trackPageView:function()
  {
    this.log('');
  },
  //訂單數(shù)據(jù)
  addTransaction:function (order_id, order_source, total, tax, shipping, gateway, city, state, country)
  {
    if(!this.prop.trans)
      this.prop.trans = {};
    
    var trans = {};
    trans.order_id = order_id;
    trans.order_source = encodeURIComponent(order_source);
    trans.total = total;
    trans.tax = tax;
    trans.shipping = shipping;
    trans.gateway = encodeURIComponent(gateway);
    trans.city = encodeURIComponent(city);
    trans.state = encodeURIComponent(state);
    trans.country = encodeURIComponent(country);
    trans.items = [];
    this.prop.trans[order_id] = trans;    
  },
  //產品數(shù)據(jù)
  addTransactionLineItem:function (order_id, sku, product_name, category, unit_price, quantity)
  {
    var li = {};
    li.li_order_id = order_id;
    li.li_sku = encodeURIComponent(sku);
    li.li_product_name = encodeURIComponent(product_name);
    li.li_category = encodeURIComponent(category);
    li.li_unit_price = encodeURIComponent(unit_price);
    li.li_quantity = quantity;
    var order = this.prop.trans[order_id];
    var items = order['items'];
    items.push(li);
    order['items'] = items;
    this.prop.trans[order_id] = order;
  },
  trackTransaction:function()
  {
    var param = "";
    for(var o in this.prop.trans)
    {
      for(var k in this.prop.trans[o])
      {
        var v = this.prop.trans[o][k];
        if(typeof v === 'object')
          for(var t in v)
            for(ta in v[t])
              param += "&" + ta + "=" + v[t][ta];
        else
          param += "&" + k + "=" + v;
      }
    }
    this.log(param);
  },
  //構建URL
  buildUrl:function (param)
  {
    var that = this.tracker;
    var url = "";
    url += this.host;
    url += "?siteid=" + that.siteid;
    url += "&visitor_id=" + this.getVisitorId();
    url += "&page_title=" + this.getPageTitle();
    url += "&tourl=" + this.getUrl();
    url += "&referrer=" + this.getReferrer();
    url += param;
    url += "&version=" + this.version;
    return url;
  },
  setCookie:function (name, value, days, path, domain, secure)
  {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var domain_arr = location.hostname.split('.');
    
    if(domain_arr.length == 2)
      domain = location.hostname;
    else    
    {
      domain_arr.shift();
      domain = "." + domain_arr.join('.');
    }    
    document.cookie = name + "=" + escape(value) +
      ((days) ? "; expires=" + date.toGMTString() : "") +
      "; path=/"    +
      "; domain=" + domain +
      ((secure) ? "; secure" : "");
  },
  readAllCookies : function ()
  {
    var jar = {};
    var ca = document.cookie.split(';');
    if (ca) {
      for (var i = 0; i < ca.length; i++) {
        var cat = this.util.trim(ca[i]);
        var pos = this.util.strpos(cat, '=');
        var key = cat.substring(0, pos);
        var value = cat.substring(pos + 1, cat.length);
        if (!jar.hasOwnProperty(key)) {
          jar[key] = [];
        }
        jar[key].push(value);
      }
      return jar;
    }
  },
  getCookie : function (name)    
  {
    var jar = this.readAllCookies();
    if (jar) {
      if (jar.hasOwnProperty(name)) {
        return jar[name][0];
      } else {
        return "";
      }
    }
  },
  getTimestamp:function()
  {
    return Math.round(new Date().getTime() / 1000);
  },
  getVisitorId:function()
  {
    
    var visitorId = this.getCookie("lk_vuid");
    if(visitorId)
    {
      return visitorId;
    }
    else
    {
      var time = new Date().getTime();
      var random = Math.round(Math.random() * 1000000);
      visitorId = time + "" + random;
      this.setVisitorId(visitorId);
      return visitorId;
    }
  },
  setVisitorId:function(visitorId)
  {
    this.setCookie('lk_vuid', visitorId, this.expire_days);
  },
  getPageTitle:function()
  {
    try {
                                var t = document.getElementsByTagName("title");
                                return encodeURIComponent(t[0].text);
                } catch (e) {return "";}
    //var t = document.getElementsByTagName("title");
    //return t == null ? encodeURIComponent(t[0].text) : '';
  },
  getUrl:function()
  {
    //訪問 URL
    var tourl = location.href;
    return encodeURIComponent(tourl);
  },
  getReferrer:function()
  {
    //來源URL
    var referrer = document.referrer;
    return encodeURIComponent(referrer);
  },
  util:{
    trim:function(str)
    {
      return str.replace(/(^\s+)|(\s+$)/, '');
    },
    strpos:function(haystack, needle, offset)
    {
      var i = (haystack + '').indexOf(needle, (offset || 0));
      return i === -1 ? false : i;
    }
  }
};

(function(){
  var lk = LK;
  lk.host = "http://192.168.3.250/__lk.gif";
  if(lk_cmds)
    lk.cmds = lk_cmds;
    
  lk.submit();
})();    
 
其中
//處理命令隊列 
  
submit:function()    
    {    
        this.tracker();    
        for(var i in this.cmds)    
        {    
            line = this.cmds[i];    
            //Array.prototype.slice這句就是訪問Array的內置方法    
            var args = Array.prototype.slice.call(line, 1);    
            if(!window[this.key])    
                window[this.key] = this;    
            window[this.key][line[0]].apply(this.tracker, args);    
        }    
 
Array.prototype.slice這句就是訪問Array的內置方法
 
相關信息查看  JS 有趣的應用 : Array.prototype.slice.call(arguments,0)
 
基本統(tǒng)計代碼:
<!-- Start LK Wise Attribution System Tracker -->
<script type="text/javascript">
//<![CDATA[
var lk_cmds =[];
lk_cmds.push(['setSiteId', 'Y8CG26ZF']);
lk_cmds.push(['trackPageView']);
(function() {
  var _lk = document.createElement('script'); _lk.type = 'text/javascript'; _lk.async = true;
        _lk.src = 'http://www.zikker.com/lk_t_compress.js';
        var _lk_s = document.getElementsByTagName('script')[0]; _lk_s.parentNode.insertBefore(_lk, _lk_s);
}());
//]]>
</script>
<!-- End LK Wise Attribution System Code -->
 
訂單統(tǒng)計代碼
下面紅色標識部分是您需要針對自己的訂單進行修改的部分,參數(shù)含義如下
訂單數(shù)據(jù)addTransaction: order_id(訂單號), order_source(訂單來源), total(訂單金額[總和]), tax(稅), shipping(運費), gateway(途徑), city(城市), state(省), country(國家)
產品數(shù)據(jù)addTransactionLineItem: order_id(訂單號), sku(產品SKU[品牌]), product_name(產品名稱), category(各類,類別), unit_price(單價), quantity(購買產品數(shù)量)
 


<script type="text/javascript">
//<![CDATA[
var lk_cmds = lk_cmds || [];
lk_cmds.push(['setSiteId', 'Y8CG26ZF']);
lk_cmds.push(['addTransaction','order_id', 'order_source', 'total', 'tax', 'shipping', 'gateway', 'city', 'state', 'country']);
lk_cmds.push(['addTransactionLineItem','order_id', 'sku', 'product_name', 'category', 'unit_price', 'quantity']);
lk_cmds.push(['trackTransaction']);

(function() {
var _lk = document.createElement('script'); _lk.type = 'text/javascript'; _lk.async = true;
_lk.src = 'http://192.168.3.250/lk_t_compress.js';
var _lk_s = document.getElementsByTagName('script')[0]; _lk_s.parentNode.insertBefore(_lk, _lk_s);
}());
//]]>
</script>
 
 
使用示例:
利用Javasctipt方式進行跟蹤, 復制以下代碼,粘貼到您的HTML頁面中用來跟蹤您的網站頁面的流量。Javascript 跟蹤API 跟蹤您的網站和網頁流量
<!-- Start LK Wise Attribution System Tracker -->
<script type="text/javascript">
//<![CDATA[
var lk_cmds = lk_cmds || [];
lk_cmds.push(['setSiteId', 'Y8CG26ZF']);
lk_cmds.push(['trackPageView']);
(function() {
                var _lk = document.createElement('script'); _lk.type = 'text/javascript'; _lk.async = true;
        _lk.src = 'http://192.168.3.250/lk_t.js';
        var _lk_s = document.getElementsByTagName('script')[0]; _lk_s.parentNode.insertBefore(_lk, _lk_s);
}());
//]]>
</script>
<!-- End LK Wise Attribution System Code -->

<script type="text/javascript">
//<![CDATA[
var lk_cmds = lk_cmds || [];
lk_cmds.push(['setSiteId', 'Y8CG26ZF']);
lk_cmds.push(['addTransaction','123', 'baidu.com', '222', '15', '10', '快遞', '北京', '北京', '中國']);
lk_cmds.push(['addTransactionLineItem','123', '九陽', '壓力鍋', '壓力鍋', '222', '1']);
lk_cmds.push(['trackTransaction']);

(function() {
var _lk = document.createElement('script'); _lk.type = 'text/javascript'; _lk.async = true;
_lk.src = 'http://192.168.3.250/lk_t.js';
var _lk_s = document.getElementsByTagName('script')[0]; _lk_s.parentNode.insertBefore(_lk, _lk_s);
}());
//]]>
</script>

分享名稱:js追蹤腳本
URL標題:http://jinyejixie.com/article6/iehoig.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供網站營銷、網站內鏈、網頁設計公司、自適應網站全網營銷推廣、響應式網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
肇源县| 德清县| 张掖市| 民权县| 葫芦岛市| 邢台县| 清远市| 荆州市| 沂源县| 高阳县| 忻城县| 武威市| 沭阳县| 江达县| 平罗县| 呼伦贝尔市| 泗洪县| 利津县| 马鞍山市| 巴南区| 南部县| 聂拉木县| 合肥市| 西乡县| 图木舒克市| 全南县| 泰州市| 乃东县| 南部县| 休宁县| 丹凤县| 崇义县| 玉溪市| 平陆县| 武威市| 常宁市| 永宁县| 嫩江县| 叙永县| 赤峰市| 思南县|