Fri Apr 07 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
    <script type="text/javascript">

  // Here is the monitor tag. This should go in the <head> of all your pages (in the template). 
  // This can be in an included script file or just in the source code.
  // Mobile Liveperson exists in promo_layer.js
  // Mobile EE exists at the bottom of <body>

  // ********************************************
  // BEGIN LivePerson Monitor.
  // ********************************************


    window.lpTag=window.lpTag||{};if(typeof window.lpTag._tagCount==='undefined'){window.lpTag={site:'14319287'||'',section:lpTag.section||'',autoStart:lpTag.autoStart===false?false:true,ovr:lpTag.ovr||{},_v:'1.6.0',_tagCount:1,protocol:'https:',events:{bind:function(app,ev,fn){lpTag.defer(function(){lpTag.events.bind(app,ev,fn);},0);},trigger:function(app,ev,json){lpTag.defer(function(){lpTag.events.trigger(app,ev,json);},1);}},defer:function(fn,fnType){if(fnType==0){this._defB=this._defB||[];this._defB.push(fn);}else if(fnType==1){this._defT=this._defT||[];this._defT.push(fn);}else{this._defL=this._defL||[];this._defL.push(fn);}},load:function(src,chr,id){var t=this;setTimeout(function(){t._load(src,chr,id);},0);},_load:function(src,chr,id){var url=src;if(!src){url=this.protocol+'//'+((this.ovr&&this.ovr.domain)?this.ovr.domain:'lptag.liveperson.net')+'/tag/tag.js?site='+this.site;}var s=document.createElement('script');s.setAttribute('charset',chr?chr:'UTF-8');if(id){s.setAttribute('id',id);}s.setAttribute('src',url);document.getElementsByTagName('head').item(0).appendChild(s);},init:function(){this._timing=this._timing||{};this._timing.start=(new Date()).getTime();var that=this;if(window.attachEvent){window.attachEvent('onload',function(){that._domReady('domReady');});}else{window.addEventListener('DOMContentLoaded',function(){that._domReady('contReady');},false);window.addEventListener('load',function(){that._domReady('domReady');},false);}if(typeof(window._lptStop)=='undefined'){this.load();}},start:function(){this.autoStart=true;},_domReady:function(n){if(!this.isDom){this.isDom=true;this.events.trigger('LPT','DOM_READY',{t:n});}this._timing[n]=(new Date()).getTime();},vars:lpTag.vars||[],dbs:lpTag.dbs||[],ctn:lpTag.ctn||[],sdes:lpTag.sdes||[],ev:lpTag.ev||[]};lpTag.init();}else{window.lpTag._tagCount+=1;}


  // ********************************************
  // NAVBAR INFORMATION
  // ********************************************

  // nav element for livechat desktop:
  // <li id="lp-chat-header"></li>
  // nav element for livechat mobile:
  // <div id="mobile-chat"></div>  


  // ********************************************
  // LIVEPERSON ENGAGEMENT ATTRIBUTES CONFIG
  // ********************************************


    lpTag.sdes = lpTag.sdes||[];

    // GLOBAL VARIABLES
    var productsInCart = [],
      cartTotal = "",
      cartCount = "",
      pageName = window.location.pathname,
      livepersonCartUpdate = /cart/.test(pageName),
      livepersonCartStd = /store_view/.test(pageName),
      livepersonCartSuccess = /success/.test(pageName),
      lpPage = window.location.href,
      lpl = false;



    // ALL PAGES : if user loads page : send community, channel, and page data
    livepersonSection();



    // CAMPAIGN PAGES : if campaign exists for user : send marketing campaign data
    if(parameterExists('cid'))livepersonMrktInfo();



    // CART PAGES :
    // if user purchases sucessfully : submit cart data for liveperson revenue tracking
    // if user updates cart : send cart product data
    if(livepersonCartStd){
      if(livepersonCartSuccess)livepersonConfirmPurchase();
      if(livepersonCartUpdate)livepersonUpdateCartProducts();
    }


    // if user submits EE form : send confirmation
    if(/business|k12/.test(lpPage) && /thanks=true/.test(lpPage)){livepersonEELead()}
    if(/empresa/.test(lpPage) && /confirmacion/.test(lpPage)){livepersonEELead()}

      
    // DEMO EMAIL SUBMIT :
    // if non EE user submits email for demo : send demo language
    if(!/business|k12/.test(lpPage)){jQuery(document).on('demo_email', function(){livepersonDemoLead();});}
    if(/\/demo/.test(document.referrer) && /lpl=true/.test(document.referrer)){livepersonDemoLead();}


    // SECTION OPTIONS
    
    // english business| english education| english consumer| english cart| english homepage
    // spanish business| spanish education| spanish consumer| spanish cart| spanish homepage
      

    // update to contains, not equals
    function livepersonSection(){
      // ENGLISH CONSUMER BY DEFAULT
      var section = "english consumer";
      // SPANISH CONSUMER 
      if(/espanol/.test(lpPage)){section = "spanish consumer";}
      // ENGLISH || SPANISH HOMEPAGE
      if(pageName == "/"){section = /espanol/.test(lpPage) ? "spanish homepage" : "english homepage";}
      // ENGLISH BUSINESS
      if(/business/.test(lpPage)){section = "english business";}
      // ENGLISH EDUCATION
      if(/k12/.test(lpPage)){section = "english education";}
      // SPANISH BUSINESS
      if(/empresa|sector-publico/.test(lpPage)){section = "spanish business";}
      // SPANISH EDUCATION
      if(/educacion/.test(lpPage)){section = "spanish education";}
      // ENGLISH CART
      if(livepersonCartStd && /us_en_/.test(lpPage)){section = "english cart";}
      // SPANISH CART
      if(livepersonCartStd && /hispanic/.test(lpPage)){section = "spanish cart";}

      lpTag.section = [section];
    }



    function livepersonMrktInfo(){
      var livepersonCID = getParameter('cid')
      var livepersonCIDChannel = livepersonCID.substring(0,2);
      var lpMrkt = livepersonCIDChannel == "se" ? livepersonCID.substring(0,5) : livepersonCIDChannel;
      var livepersonMrkt = {"oo":"0","se-nb":"1","sm":"2","em":"3","af":"4","se-br":"5","ba":"6"};
      lpTag.sdes.push({
        "type": "mrktInfo",
          "info": {
            "channel": livepersonMrkt[lpMrkt]
          }
      });
    }



    function livepersonDemoLead(){
      lpTag.sdes.push({
        "type": "lead",
        "lead": {
          "topic": "demo form"
        }
      });
    }


    function livepersonEELead(){
      
      var eelead = /business|empresa/.test(lpPage) ? "business lead" : "education lead";

      lpTag.sdes.push({
        "type": "lead",
        "lead": {
          "topic": eelead
        }
      });
    }


    function livepersonConfirmPurchase(){
      livepersonProducts();

      lpTag.sdes.push({
        "type": "purchase",
        "total": cartTotal,
        "numItems": cartCount,
        "orderId":rs.orderid,
        "cart":{
          "products": productsInCart
        }
      });
    }



    function livepersonUpdateCartProducts(){
      livepersonProducts();
      
      lpTag.sdes.push({
        "type": "cart",
        "total": cartTotal,
        "numItems": cartCount,
        "products": productsInCart
      });
    }



    function livepersonProducts(){

      cartTotal = rs.pixp_total;
      cartCount = rs.pixp_cartCount;

      var skus = rs.pixp_sku.split(','),
        languages = rs.pixp_lang.split(','),
        versions = rs.pixp_vers.split(','),
        names = rs.pixp_name.split(','),
        prices = rs.pixp_price.split(','),
        quantities = rs.pixp_qty.split(',');

      for (var i = 0; i < cartCount; i++){
        var livepersonVersion = languages[i] + " " + versions[i];
        productsInCart.push({
          "product":{
            "name":names[i],
            "category": livepersonVersion,
            "sku":skus[i],
            "price":prices[i]
          },
          "quantity":quantities[i]
        });
      }
    }



    function parameterExists(param){
      var reg = new RegExp('[?&]'+param+'=','i');
      return !!window.location.search.match(reg);
    }



    function getParameter(param){
      var reg = new RegExp('[?&]'+param+'=([^&]+)','i');
      return parameterExists(param) ? window.location.search.match(reg).pop() : '';
    }
  </script>