PageSourceSearch

https://dongmanmanhua.cn/js/lib/ga_logger.js

js dongmanmanhua.cn collected 2026-10-02 03:05:22 UTC 3,843 bytes, 165 lines download raw bytes

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.