PageSourceSearch

https://dwvil.com/js/fb_pixel.js?1790660974

js dwvil.com collected 2026-10-02 00:30:20 UTC 8,195 bytes, 218 lines download raw bytes

1var FB_PIXEL = function(){
2	var order_info = [];
3	var ViewContent = function(id,name,value,currency){	/* 컨텐츠 조회 */
4		if(typeof fbq != 'undefined'){
5			fbq('track', 'ViewContent', {
6				content_type : 'product',
7				content_ids : id,
8				content_name : name,
9				contents : [{"id": id, "quantity": 1, "item_price": value}],
10				value : parseInt(value).toFixed(2),
11				currency : currency
12			});
13		}
14	};
15	var AddOrderInfo = function(idx,ea,price){
16		order_info.push({
17			'id' : idx,
18			'quantity' : ea,
19			'item_price' : price,
20			'type' : 'product'
21		});
22	};
23
24	var AddToCart = function(id, name, price,currency,count,total_price,event_id,fb_external_id){	/* 장바구니 추가 */
25		if (typeof fbq != 'undefined') fbq('track', 'AddToCart',{
26			content_ids : id,
27			content_type : 'product',
28			content_name : name,
29			contents : [{"id": id, "quantity": count, "item_price": price}],
30			value : parseInt(price).toFixed(2),
31			currency : currency
32		},{eventID : event_id});
33	};
34	// 전용 API의 존재가 dry-run 지원 계약이다. 기존 8인자 송신 API와 분리한다.
35	var AddToCartDryRun = function(id, name, price, currency, count, total_price, event_id, fb_external_id, compatibility){
36		var valid = compatibility !== null && typeof compatibility === 'object' && !Array.isArray(compatibility)
37			&& Object.keys(compatibility).sort().join(',') === 'compatibility_target,event_name,mode,projection'
38			&& compatibility.mode === 'dry_run' && compatibility.event_name === 'AddToCart'
39			&& typeof compatibility.compatibility_target === 'boolean';
40		var projection = valid ? compatibility.projection : null;
41		if (valid && projection !== null) {
42			valid = compatibility.compatibility_target === true
43				&& typeof projection === 'object' && !Array.isArray(projection)
44				&& Object.keys(projection).sort().join(',') === 'pixel_id,product_id'
45				&& typeof projection.pixel_id === 'string' && projection.pixel_id.length >= 1 && projection.pixel_id.length <= 100 && !/[^0-9]/.test(projection.pixel_id)
46				&& typeof projection.product_id === 'string';
47		}
48		var applied = valid && projection !== null;
49		var product_id = applied ? projection.product_id : id;
50		// 응답 원문과 개인 식별자는 기록하지 않는다. 관측 실패도 송신으로 재시도하지 않는다.
51		try {
52			if (typeof console !== 'undefined' && typeof console.info === 'function') {
53				console.info('[FS-3585][META_EVENT_DRY_RUN]', {
54					feature_key: 'FS-3585', mode: 'dry_run', provider: 'meta', event_name: 'AddToCart',
55					disposition: !valid ? 'invalid_response' : (applied ? 'projection_applied' : 'projection_absent'),
56					compatibility_applied: applied,
57					pixel_override: applied, pixel_id: applied ? projection.pixel_id : null,
58					payload: {
59						content_ids: product_id, content_type: 'product', content_name: name,
60						contents: [{id: product_id, quantity: count, item_price: price}],
61						value: parseInt(price).toFixed(2), currency: currency
62					},
63					options: {eventID: event_id}
64				});
65			}
66		} catch (e) { /* 관측 실패는 장바구니 성공에 영향을 주지 않는다. */ }
67	};
68	var AddToWishlist = function(){	/* 위시리스트 추가 */
69		//console.log("FB_PIXEL - AddToWishlist");
70		if (typeof fbq != 'undefined') fbq('track', 'AddToWishlist');
71	};
72	var InitiateCheckout = function(event_id,total_price,currency,fb_external_id){	/* 결제시작 */
73		if (typeof fbq != 'undefined') {
74			//console.log("FB_PIXEL - InitiateCheckout");
75			if (typeof fbq != 'undefined') fbq('track', 'InitiateCheckout', {
76				value: parseInt(total_price).toFixed(2),
77				currency: currency
78			}, {eventID: event_id});
79		}
80	};
81	var AddPaymentInfo = function(){	/* 결제 정보 추가 */
82		//console.log("FB_PIXEL - AddPaymentInfo");
83		if (typeof fbq != 'undefined') fbq('track', 'AddPaymentInfo');
84	};
85	var Purchase = function(value,currency,flag_code,fb_external_id){
86		/* 결제 완료 */
87		var dispatchPurchase = function() {
88			var content_ids = [];
89			/* content_ids 설정 - order_info 에서 id만 뽑아서 생성해준다. */
90			order_info.forEach(function(obj) {
91				if (content_ids.indexOf(obj.id) == -1) content_ids.push(obj.id);
92			});
93
94			console.log("dispatchPurchaseFree : ", value, ", ", currency);
95			// value가 숫자이고 currency가 존재할 때만 track
96			if (!isNaN(parseFloat(value)) && currency) {
97				console.log("dispatchPurchaseTrack : ", value, ", ", currency);
98				// Purchase 이벤트 전송
99				fbq('track', 'Purchase', {
100					content_ids: content_ids,
101					content_type: 'product',
102					contents: order_info,
103					value: parseFloat(value),
104					currency: currency
105				}, { eventID: flag_code });
106			}
107		};
108
109		// fbq가 이미 로드되어 있으면 즉시 전송
110		if (typeof fbq !== 'undefined') {
111			dispatchPurchase();
112			return;
113		}
114
115		// window.fbq 할당 감지를 위한 descriptor 사용
116		var originalFbq = window.fbq;
117		var fbqDetected = false;
118
119		try {
120			// Object.defineProperty를 사용해서 fbq 할당 감지
121			Object.defineProperty(window, 'fbq', {
122				get: function() {
123					return originalFbq;
124				},
125				set: function(value) {
126					originalFbq = value;
127					if (!fbqDetected && typeof value === 'function') {
128						fbqDetected = true;
129						setTimeout(function() {
130							dispatchPurchase();
131						}, 0);
132					}
133				},
134				configurable: true
135			});
136		} catch(e) {
137			// defineProperty가 실패하는 경우 (IE8 등) 폴백
138			var checkFbq = function() {
139				if (typeof window.fbq !== 'undefined' && !fbqDetected) {
140					fbqDetected = true;
141					dispatchPurchase();
142				} else if (!fbqDetected) {
143					setTimeout(checkFbq, 100);
144				}
145			};
146			setTimeout(checkFbq, 100);
147		}
148
149		// 10초 타임아웃으로 강제 정리
150		setTimeout(function() {
151			fbqDetected = true; // 더 이상 감지하지 않음
152		}, 10000);
153	};
154	var CompleteRegistration = function(type,currency,id){
155		if(type == 'join'){
156			if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'id' : id , 'value' : 0, 'currency' : currency});
157		}else{
158			if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'value' : 0, 'currency' : currency});
159		}
160	};
161
162
163	var use_npay_count = false;
164	var setUseNpayCount = function(b){
165		use_npay_count = (b === true);
166	};
167	var addNpayOrder = function(order_data){
168		if(!use_npay_count) return false;
169		if( typeof order_data == 'undefined') return false;
170		if( typeof order_data['list'] == 'undefined') return false;
171		// 네이버 페이도 구매전환에 포함하게끔 옵션을 사용할 경우에는 구매완료를 바로 보낸다
172
173		var np_fb_data = {'total_price': 0, 'currency': order_data['currency']};
174		var npay_order_item = {};
175		for(var i = 0; i<order_data['list'].length; i++){
176			npay_order_item = order_data['list'][i];
177			AddOrderInfo(npay_order_item['prod_idx'], npay_order_item['count'], npay_order_item['price']);
178		}
179		np_fb_data['total_price'] = order_data['total_price'];
180		np_fb_data['pc_event_id'] = order_data['pc_event_id'];
181		np_fb_data['fb_external_id'] = order_data['fb_external_id'];
182
183		Purchase(np_fb_data['total_price'], np_fb_data['currency'], np_fb_data['pc_event_id'],np_fb_data['fb_external_id']);
184	};
185	return {
186		"ViewContent" : function(id,name,value,currency){
187			ViewContent(id,name,value,currency);
188		},
189		"AddToCart" : function(id, name, price,currency,count,total_price,event_id,fb_external_id){
190			AddToCart(id, name, price,currency,count,total_price,event_id,fb_external_id);
191		},
192		"AddToCartDryRun" : AddToCartDryRun,
193		"AddOrderInfo" : function(idx,ea,price){
194			AddOrderInfo(idx,ea,price);
195		},
196		"AddToWishlist" : function(){
197			AddToWishlist();
198		},
199		"InitiateCheckout" : function(event_id,total_price,currency,fb_external_id){
200			InitiateCheckout(event_id,total_price,currency,fb_external_id);
201		},
202		"AddPaymentInfo" : function(){
203			AddPaymentInfo();
204		},
205		"Purchase" : function(value,currency,order_no,fb_external_id){
206			Purchase(value,currency,order_no,fb_external_id);
207		},
208		"CompleteRegistration" : function(type,currency,id){
209			CompleteRegistration(type,currency,id);
210		},
211		"setUseNpayCount": function(b){
212			setUseNpayCount(b);
213		},
214		"addNpayOrder" : function(order_data){
215			addNpayOrder(order_data);
216		}
217	}
218}();

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.