PageSourceSearch

https://shop.sqcf.org/js/fb_pixel.js?1768291297

js sqcf.org collected 2026-09-24 10:12:58 UTC 6,023 bytes, 183 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	var AddToWishlist = function(){	/* 위시리스트 추가 */
35		//console.log("FB_PIXEL - AddToWishlist");
36		if (typeof fbq != 'undefined') fbq('track', 'AddToWishlist');
37	};
38	var InitiateCheckout = function(event_id,total_price,currency,fb_external_id){	/* 결제시작 */
39		if (typeof fbq != 'undefined') {
40			//console.log("FB_PIXEL - InitiateCheckout");
41			if (typeof fbq != 'undefined') fbq('track', 'InitiateCheckout', {
42				value: parseInt(total_price).toFixed(2),
43				currency: currency
44			}, {eventID: event_id});
45		}
46	};
47	var AddPaymentInfo = function(){	/* 결제 정보 추가 */
48		//console.log("FB_PIXEL - AddPaymentInfo");
49		if (typeof fbq != 'undefined') fbq('track', 'AddPaymentInfo');
50	};
51	var Purchase = function(value,currency,flag_code,fb_external_id){
52		/* 결제 완료 */
53		var dispatchPurchase = function() {
54			var content_ids = [];
55			/* content_ids 설정 - order_info 에서 id만 뽑아서 생성해준다. */
56			order_info.forEach(function(obj) {
57				if (content_ids.indexOf(obj.id) == -1) content_ids.push(obj.id);
58			});
59
60			console.log("dispatchPurchaseFree : ", value, ", ", currency);
61			// value가 숫자이고 currency가 존재할 때만 track
62			if (!isNaN(parseFloat(value)) && currency) {
63				console.log("dispatchPurchaseTrack : ", value, ", ", currency);
64				// Purchase 이벤트 전송
65				fbq('track', 'Purchase', {
66					content_ids: content_ids,
67					content_type: 'product',
68					contents: order_info,
69					value: parseFloat(value),
70					currency: currency
71				}, { eventID: flag_code });
72			}
73		};
74
75		// fbq가 이미 로드되어 있으면 즉시 전송
76		if (typeof fbq !== 'undefined') {
77			dispatchPurchase();
78			return;
79		}
80
81		// window.fbq 할당 감지를 위한 descriptor 사용
82		var originalFbq = window.fbq;
83		var fbqDetected = false;
84
85		try {
86			// Object.defineProperty를 사용해서 fbq 할당 감지
87			Object.defineProperty(window, 'fbq', {
88				get: function() {
89					return originalFbq;
90				},
91				set: function(value) {
92					originalFbq = value;
93					if (!fbqDetected && typeof value === 'function') {
94						fbqDetected = true;
95						setTimeout(function() {
96							dispatchPurchase();
97						}, 0);
98					}
99				},
100				configurable: true
101			});
102		} catch(e) {
103			// defineProperty가 실패하는 경우 (IE8 등) 폴백
104			var checkFbq = function() {
105				if (typeof window.fbq !== 'undefined' && !fbqDetected) {
106					fbqDetected = true;
107					dispatchPurchase();
108				} else if (!fbqDetected) {
109					setTimeout(checkFbq, 100);
110				}
111			};
112			setTimeout(checkFbq, 100);
113		}
114
115		// 10초 타임아웃으로 강제 정리
116		setTimeout(function() {
117			fbqDetected = true; // 더 이상 감지하지 않음
118		}, 10000);
119	};
120	var CompleteRegistration = function(type,currency,id){
121		if(type == 'join'){
122			if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'id' : id , 'value' : 0, 'currency' : currency});
123		}else{
124			if (typeof fbq != 'undefined') fbq('track', 'CompleteRegistration',{'value' : 0, 'currency' : currency});
125		}
126	};
127
128
129	var use_npay_count = false;
130	var setUseNpayCount = function(b){
131		use_npay_count = (b === true);
132	};
133	var addNpayOrder = function(order_data){
134		if(!use_npay_count) return false;
135		if( typeof order_data == 'undefined') return false;
136		if( typeof order_data['list'] == 'undefined') return false;
137		// 네이버 페이도 구매전환에 포함하게끔 옵션을 사용할 경우에는 구매완료를 바로 보낸다
138
139		var np_fb_data = {'total_price': 0, 'currency': order_data['currency']};
140		var npay_order_item = {};
141		for(var i = 0; i<order_data['list'].length; i++){
142			npay_order_item = order_data['list'][i];
143			AddOrderInfo(npay_order_item['prod_idx'], npay_order_item['count'], npay_order_item['price']);
144		}
145		np_fb_data['total_price'] = order_data['total_price'];
146		np_fb_data['pc_event_id'] = order_data['pc_event_id'];
147		np_fb_data['fb_external_id'] = order_data['fb_external_id'];
148
149		Purchase(np_fb_data['total_price'], np_fb_data['currency'], np_fb_data['pc_event_id'],np_fb_data['fb_external_id']);
150	};
151	return {
152		"ViewContent" : function(id,name,value,currency){
153			ViewContent(id,name,value,currency);
154		},
155		"AddToCart" : function(id, name, price,currency,count,total_price,event_id,fb_external_id){
156			AddToCart(id, name, price,currency,count,total_price,event_id,fb_external_id);
157		},
158		"AddOrderInfo" : function(idx,ea,price){
159			AddOrderInfo(idx,ea,price);
160		},
161		"AddToWishlist" : function(){
162			AddToWishlist();
163		},
164		"InitiateCheckout" : function(event_id,total_price,currency,fb_external_id){
165			InitiateCheckout(event_id,total_price,currency,fb_external_id);
166		},
167		"AddPaymentInfo" : function(){
168			AddPaymentInfo();
169		},
170		"Purchase" : function(value,currency,order_no,fb_external_id){
171			Purchase(value,currency,order_no,fb_external_id);
172		},
173		"CompleteRegistration" : function(type,currency,id){
174			CompleteRegistration(type,currency,id);
175		},
176		"setUseNpayCount": function(b){
177			setUseNpayCount(b);
178		},
179		"addNpayOrder" : function(order_data){
180			addNpayOrder(order_data);
181		}
182	}
183}();

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.