1/** 2 * ga_logger.js 3 */ 4var GaLogger = GaLogger || { 5 id : undefined 6 , isInit : false 7 , dimensions : {} 8 , pendingDimensions : {} 9 , readInfo : { 10 eventLabel : '' 11 , callReadComplete : false 12 } 13 /** 14 * ì´ê¸°í 15 */ 16 , init : function(id) { 17 if(this.isInit) { 18 return; 19 } 20 21 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 22 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 23 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 24 })(window,document,'script','','ga'); /*廿æä»¶//www.google-analytics.com/analytics.jsï¼å è½½ä¸å°çå¾ æ¶é´è¿é¿*/ 25 26 this.id = id; 27 ga('create', this.id, 'auto'); 28 this.isInit = true; 29 } 30 31 /** 32 * dimension ì¤ì 33 */ 34 , set : function(dimension, value) { 35 if(this.isInit) { 36 ga('set', dimension, value); 37 this.dimensions[dimension] = value; 38 } else { 39 this.pendingDimensions[dimension] = value; 40 } 41 } 42 43 /** 44 * display features plugin ì¤ì 45 */ 46 , displayfeatures : function() { 47 this._ga('require', 'displayfeatures'); 48 } 49 50 /** 51 * PV í¸ì¶ 52 */ 53 , pageView : function() { 54 this._ga('send', 'pageview'); 55 } 56 57 /** 58 * íì°¨ read ì´ë²¤í¸ í¸ì¶ 59 */ 60 , episodeRead : function(eventLabel, dimensions) { 61 this.readInfo.eventLabel = eventLabel; 62 var oDimension = { 63 'dimension2' : dimensions.titleNo 64 , 'dimension3' : dimensions.episodeNo 65 , 'dimension9' : dimensions.weekday 66 , 'dimension11' : dimensions.genre 67 }; 68 this.gaEventLoggingByDimensions('Read', 'Read_Episode', this.readInfo.eventLabel, oDimension); 69 } 70 71 /** 72 * íì°¨ read Complete ì´ë²¤í¸ í¸ì¶ 73 */ 74 , episodeReadComplete : function() { 75 if(!this.readInfo.eventLabel) { 76 return; 77 } 78 79 if(this.readInfo.callReadComplete) { 80 return; 81 } 82 83 this.readInfo.callReadComplete = true; 84 this.gaEventLoggingByDimensions('Read', 'Read_Complete', this.readInfo.eventLabel); 85 } 86 87 /** 88 * GA Event ë¡ê¹ 89 * 90 * @param eventCategory 91 * @param eventAction 92 * @param eventLabel 93 * @param titleNo 94 * @param episodeNo 95 */ 96 , gaEventLogging : function(eventCategory, eventAction, eventLabel, titleNo, episodeNo) { 97 this._clearDimensions(); 98 99 if (titleNo) { 100 this.set('dimension2', titleNo); 101 } 102 103 if(episodeNo) { 104 this.set('dimension3', episodeNo); 105 } 106 107 this._ga('send', 'event', eventCategory, eventAction, eventLabel); 108 } 109 110 /** 111 * GA Event ë¡ê¹ 112 * 113 * @param eventCategory 114 * @param eventAction 115 * @param eventLabel 116 * @param dimensions 117 */ 118 , gaEventLoggingByDimensions : function(eventCategory, eventAction, eventLabel, dimensions) { 119 this._clearDimensions(); 120 if(dimensions) { 121 for(var key in dimensions) { 122 this.set(key, dimensions[key]); 123 } 124 } 125 126 this._ga('send', 'event', eventCategory, eventAction, eventLabel); 127 } 128 129 /** 130 * GA function ìí 131 */ 132 , _ga : function(command, hitType, category, action, label) { 133 this._addPendingDimensions(); 134 ga(command, hitType, category, action, label); 135 } 136 137 /** 138 * ì¶ê°ëì§ ìì dimensions ì¶ê° 139 */ 140 , _addPendingDimensions : function() { 141 for(var key in this.pendingDimensions) { 142 this.set(key, this.pendingDimensions[key]); 143 } 144 } 145 146 /** 147 * dimensions clear 148 * - íë² ì¶ê°ë dimensionsì íì´ì§ê° ë³ê²½ëì§ ììí ì´ì ì기 ë문ì ì´ë¥¼ clearí´ì¤ë¤. 149 * - dimensions4 (contentLanguage)ë clearíì§ ìì 150 * @private 151 */ 152 , _clearDimensions : function() { 153 if(Object.keys(this.dimensions).length < 1) { 154 return; 155 } 156 157 for(var key in this.dimensions) { 158 if( key != "dimension4") { 159 delete this.dimensions[key]; 160 // ga dimension setting ì ê±° 161 ga('set', key, null); 162 } 163 } 164 } 165};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.