· 7 years ago · Jun 28, 2018, 10:34 AM
1--- ПОЛУЧÐЕМ КОРОТКИЙ ID из заказов ТикетÑа (нужен Ð´Ð»Ñ Ð½ÐµÐºÐ¾Ñ‚Ð¾Ñ€Ñ‹Ñ… партнерок)
2
3 var partners_shortId = currentSearch.bookingId;
4 if (partners_shortId.indexOf('_') != -1)
5 partners_shortId = partners_shortId.split('_')[1];
6
7
8Ð’ СЛУЧÐЕ ЕСЛИ utm_source задан (или кука партнера) из ÑпиÑка utm-меток
9
10 if (currentSearch.isPartner == 1)
11 {
12
13
14Дальше у каждой партнерки еÑть Ñвои обÑзательные параметры (не у вÑех, пишутÑÑ Ð² s_partner_uid) и utm_source (они же пишутÑÑ Ð² куку - по правилу поÑледего партнера)
15//admitadSource - Ñто Utm_source
16//aviasalesCookie - s_partner из кук
17
18if ((admitadSource != null && admitadSource.toLowerCase() == 'paypersale') || (aviasalesCookie != '' && aviasalesCookie != null && aviasalesCookie.toLowerCase() == 'paypersale'))
19{
20 //PayPerSale
21 try {
22 $( 'body' ).append( $('<img>', {'src': '//a00.paypersale.ru/track/id/' + partners_shortId + '/akey/1392/target/t1/price/' + PRICES_VIEW.getPrice('ticket_price', 4), width: 1, height: 1}) );
23 } catch(e) {
24 console.error(admitadSource, e);
25 }
26}
27
28
29else if (admitadSource == 'tradetracker' || aviasalesCookie == 'tradetracker')
30{
31 //Tradetracker
32 try {
33 $( 'body' ).append( $('<img>', {'src': '/tradetracker/?campaignID=17240&productID=25602&conversionType=sales&transactionID=' + partners_shortId + '&transactionAmount=' + PRICES_VIEW.getPrice('ticket_price', 4) + '.00&descrAffiliate=', width: 1, height: 1}) );
34 } catch(e) {
35 console.error(admitadSource, e);
36 }
37}
38
39
40else if ((admitadSource == 'admitad' && admitadPromo != '' && admitadPromo != '0' && admitadPromo != null) || (aviasalesCookie == 'admitad' && aviasalesCookieUid != '' && aviasalesCookieUid != '0' && aviasalesCookieUid != null))
41{
42 // pixel for adMitad.ru
43 try {
44 var script = document.createElement('script')
45 script.setAttribute("type","text/javascript")
46 script.innerHTML = "(function (d, w) { w._admitadPixel = { response_type: 'img', action_code: '7', campaign_code: 'bf3e570a18' }; w._admitadPositions = w._admitadPositions || []; w._admitadPositions.push({ uid: '" + ((admitadPromo == '' || admitadPromo == '0' || admitadPromo == null) ? aviasalesCookieUid : admitadPromo) + "', order_id: '" + partners_shortId + "', tariff_code: '1', price: " + PRICES_VIEW.getPrice('ticket_price', 4) + ", currency_code: 'RUB', payment_type: 'sale' }); var id = '_admitad-pixel'; if (d.getElementById(id)) { return; } var s = d.createElement('script'); s.id = id; var r = (new Date).getTime(); var protocol = (d.location.protocol === 'https:' ? 'https:' : 'http:'); s.src = protocol + '//cdn.asbmit.com/static/js/pixel.min.js?r=' + r; d.head.appendChild(s); })(document, window)";
47 document.getElementsByTagName('body')[0].appendChild(script);
48 } catch(e) {
49 console.error(admitadSource, e);
50 }
51}
52
53else if ((admitadSource == 'actionpay' && actionpay_source != '' && actionpay_source != '0' && actionpay_source != null) || (aviasalesCookie == 'actionpay' && aviasalesCookieUid != '' && aviasalesCookieUid != '0' && aviasalesCookieUid != null))
54{
55 //pixel for Actionpay
56 try {
57 $( 'body' ).append( $('<img>', {'src': '//apypxl.com/ok/3318.png?actionpay=' + ((actionpay_source == '' || actionpay_source == '0' || actionpay_source == null) ? aviasalesCookieUid : actionpay_source) + '&apid=' + partners_shortId + '&price=' + (pint(PRICES_VIEW.getPrice('ticket_price', 4))*(2.34/100)).toFixed(2), width: 1, height: 1}) );
58 } catch(e) {
59 console.error(admitadSource, e);
60 }
61
62}
63
64else if ((admitadSource == 'cityads' && CityAdsClickId != '' && CityAdsClickId != '0' && CityAdsClickId != null) || (aviasalesCookie == 'cityads' && aviasalesCookieUid != '' && aviasalesCookieUid != '0' && aviasalesCookieUid != null))
65{
66 //pixel for CityAds
67 try {
68 var s = document.createElement("script");
69 s.type = "text/javascript";
70 s.src = '//cityadspix.com/track/' + partners_shortId + '/ct/q1/c/11345?click_id=' + ((CityAdsClickId == '' || CityAdsClickId == '0' || CityAdsClickId == null) ? aviasalesCookieUid : CityAdsClickId) + '&order_total=' + PRICES_VIEW.getPrice('ticket_price', 4) + '¤cy=RUR&customer_type=' + ((CityAdsClickId == '' || CityAdsClickId == '0' || CityAdsClickId == null) ? 'new' : 'old') + '&payment_method=' + ((currentSearch.payment_variant == 'rapida' || currentSearch.payment_variant == 'delaypay') ? 'Cash' : 'CreditCard') + '&basket=[{"fd":"' + currentSearch.from_date_ymd + '","td":"' + currentSearch.to_date_ymd + '","cl":"' + ((currentSearch.cs == 'E') ? 'economy' : 'business') + '","op":"' + currentSearch.from_code + '","dp":"' + currentSearch.to_code + '","cp":"' + (currentSearch.cn + currentSearch.in) + '","ap":"' + currentSearch.ad + '","tt":"air","cn":"' + currentSearch.companyFrom + '","up":"' + PRICES_VIEW.getPrice('ticket_price', 4) + '"}]&md=2';
71 $("body").append(s);
72 } catch(e) {
73 console.error(admitadSource, e);
74 }
75}
76
77
78
79// stats for Avia Yandex
80try {
81 var _pay_var_book = ['delaypay', 'rapida', 'rapida'];
82 if (admitadSource == 'yandex.ru' && srcmarker_aviasales != '' && srcmarker_aviasales != null && _.indexOf(_pay_var_book, currentSearch.payment_variant) < 0)
83 $( 'body' ).append( $('<img>', {'src': '//avia.yandex.ru/order/pixel/' + srcmarker_aviasales + '/paid.gif', width: 1, height: 1}) );
84} catch(e) {
85 console.error('Avia Yandex', e);
86}
87
88
89
90-------БЕЗ УСЛОВИЙ (вызываютÑÑ Ð²Ñегда на поÑледнем шаге)
91//Google Conversion
92try {
93 $( 'body' ).append( $('<img>', {'src': '//www.googleadservices.com/pagead/conversion/1006532280/?label=CRkxCIqf9mgQuO353wM&guid=ON&script=0', width: 1, height: 1}) );
94} catch(e) {
95 console.error('/Google Conversion', e);
96}
97
98var purchasedProducts = {};
99var gaProducts = [
100 { // - Передача данных о товаре (билеты)
101 'sku': currentSearch.from_code + currentSearch.to_code + currentSearch.from_date + ((currentSearch.to_date != '') ? currentSearch.to_date : ''), // - артикул товара - иÑпользуем - код города вылета + код города прилета + дата вылета туда + обратно + кол-во паÑÑажиров (в том виде в котором вам удобно, главное должно быть string)
102 'name': currentSearch.from_code + currentSearch.to_code + ((currentSearch.to_date != '') ? currentSearch.from_code : ''), // - название товара
103 'category': 'Ðвиабилеты', // - ÐºÐ°Ñ‚ÐµÐ³Ð¾Ñ€Ð¸Ñ Ñ‚Ð¾Ð²Ð°Ñ€Ð° Ð´Ð»Ñ Ð°Ð²Ð¸Ð° - вÑегда будет Ðвиабилеты
104 'price': PRICES_VIEW.getPrice('ticket_price', 4), // - передаем общую ÑтоимоÑть за билеты (без учета доп уÑлуг)
105 'quantity': 1 // - передаем вÑегда 1
106 }
107 ];
108
109//prepare additional services
110try {
111
112 var insurance = SERVICE_COLLECTION.getListSelectedServices();
113 if (insurance != undefined && insurance[0] != undefined)
114 {
115 var ix = 1;
116 for (z in insurance)
117 {
118 var cur_dop = insurance[z];
119
120 purchasedProducts[ix] = {
121 id: cur_dop.service_name,
122 name: cur_dop.service_type,
123 price: cur_dop.price,
124 quantity: 1
125 };
126
127 gaProducts.push({
128 'sku': cur_dop.service_type, // - ИÑпользуем то, что обÑудили в Скайпе
129 'name': cur_dop.service_name,
130 'category': 'Ðвиабилеты - уÑлуги',
131 'price': cur_dop.price, // - ÐžÐ±Ñ‰Ð°Ñ ÑтоимоÑть конкретной дополнительной уÑлуги.
132 'quantity': 1 // - передаем вÑегда 1
133 });
134
135 ix++;
136 }
137 }
138} catch(e) {
139 console.error('prepare additional services', e)
140}
141
142//prepare additional services BAGGAGE
143try {
144
145 var baggage = BAGGAGE_COLLECTION.getListSelectedServices();
146 if (baggage != undefined && baggage[0] != undefined)
147 {
148 gaProducts.push({
149 'sku': 'additional_baggage', // - ИÑпользуем то, что обÑудили в Скайпе
150 'name': 'Дополнительный багаж',
151 'category': 'Ðвиабилеты - уÑлуги',
152 'price': BAGGAGE_COLLECTION.getFullSumm(), // - ÐžÐ±Ñ‰Ð°Ñ ÑтоимоÑть конкретной дополнительной уÑлуги.
153 'quantity': 1 // - передаем вÑегда 1
154 });
155 }
156} catch(e) {
157 console.error('prepare additional services', e)
158}
159
160//ActionPay New
161try {
162 purchasedProducts[0] = {
163 id: currentSearch.from_code + currentSearch.to_code,
164 name: currentSearch.from_city + '-' + currentSearch.to_city + ((currentSearch.to_date != '') ? '-' + currentSearch.from_city : ''),
165 price: PRICES_VIEW.getPrice('ticket_price', 4),
166 quantity: 1
167 }
168
169 //ActionPayNew
170 if (typeof window.APRT_SEND == "function") window.APRT_SEND({
171 pageType: 6,
172 searchTickets: {
173 type: 'avia',
174 class: ((currentSearch.cs == 'E') ? 'economy' : 'business'),
175 country: codes_info[currentSearch.to_code].country_name,
176 from: currentSearch.from_city,
177 dest: currentSearch.to_city,
178 dateFrom: currentSearch.from_date_ymd,
179 dateTill: ((currentSearch.to_date != '') ? currentSearch.to_date_ymd : ''),
180 count: currentSearch.ad,
181 countChildren: currentSearch.cn,
182 countBaby: currentSearch.in,
183 codeFrom: currentSearch.from_code,
184 codeDest: currentSearch.to_code
185 },
186 // текущий проÑматриваемый продукт
187 currentProduct: {
188 id: currentSearch.from_code + currentSearch.to_code,
189 name: currentSearch.from_city + '-' + currentSearch.to_city + ((currentSearch.to_date != '') ? '-' + currentSearch.from_city : ''),
190 price: PRICES_VIEW.getPrice('ticket_price', 4)
191 },
192 // продукты выбранные пользователем
193 basketProducts: {
194 id: currentSearch.from_code + currentSearch.to_code,
195 name: currentSearch.from_city + '-' + currentSearch.to_city + ((currentSearch.o_date != '') ? '-' + currentSearch.from_city : ''),
196 price: PRICES_VIEW.getPrice('ticket_price', 4),
197 quantity: 1
198 },
199 // купленные продукты
200 purchasedProducts: purchasedProducts,
201 // Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ заказе
202 orderInfo: {
203 id: partners_shortId,
204 totalPrice: PRICES_VIEW.itog('step_4')
205 }
206});
207} catch(e) {
208 console.error('APRT', e)
209}
210
211//Facebook - recreative agency
212try {
213 var _fbq = window._fbq || (window._fbq = []);
214 if (!_fbq.loaded) {
215 var fbds = document.createElement('script');
216 fbds.async = true;
217 fbds.src = '//connect.facebook.net/en_US/fbds.js';
218 var s = document.getElementsByTagName('script')[0];
219 s.parentNode.insertBefore(fbds, s);
220 _fbq.loaded = true;
221 }
222 _fbq.push(['addPixelId', '993343380685635']);
223
224 window._fbq = window._fbq || [];
225 window._fbq.push(["track", "Purchase", {
226 content_ids: [currentSearch.from_code + currentSearch.to_code],
227 content_type: 'product'
228 }]);
229} catch (e) {
230 console.error('/Facebook - recreative agency', e);
231}
232
233//CityAds - Code - Retarget
234try {
235 xcnt_transport_currency = 'RUB';
236 xcnt_transport_price = PRICES_VIEW.getPrice('ticket_price', 4);
237 xcnt_transport_class = ((currentSearch.cs == 'E') ? 'economy' : 'business');
238 xcnt_order_id = partners_shortId;
239 xcnt_user_email = currentSearch.clientEmail;
240
241 var xscr = document.createElement( 'script' ); xscr.async = 1;
242 xscr.src = '//x.cnt.my/async/track/?r=' + Math.random();
243 document.getElementsByTagName('body')[0].appendChild(xscr);
244
245} catch (e) {
246 console.error('//CityAds - Code - Retarget', e);
247}
248
249
250//FB Code Kirill - Mobile App
251try {
252 var _fbq = window._fbq || (window._fbq = []);
253 if (!_fbq.loaded) {
254 var fbds = document.createElement('script');
255 fbds.async = true;
256 fbds.src = '//connect.facebook.net/en_US/fbds.js';
257 var s = document.getElementsByTagName('script')[0];
258 s.parentNode.insertBefore(fbds, s);
259 _fbq.loaded = true;
260 }
261 window._fbq = window._fbq || [];
262 window._fbq.push(['track', '6019215835966', {'value':PRICES_VIEW.getPrice('ticket_price', 4) + '.00','currency':'RUR'}]);
263} catch(e) {
264 console.error('//FB Code Kirill - Mobile App', e);
265}
266
267//Criteo
268try {
269 window.criteo_q = window.criteo_q || [];
270 window.criteo_q.push(
271 { event: "setAccount", account: 22486 },
272 { event: "setEmail", email: currentSearch.clientEmail },
273 { event: "setSiteType", type: "d" },
274 { event: "viewSearch", checkin_date:currentSearch.from_date_ymd, checkout_date:((currentSearch.to_date != '') ? currentSearch.to_date_ymd : '')},
275 { event: "trackTransaction" , id: partners_shortId, new_customer: '', nbra: currentSearch.ad, nbrc: currentSearch.cn, numi: currentSearch.in, nums: ((currentSearch.cs == 'E') ? 0 : 1), item: [
276 { id: currentSearch.from_code + currentSearch.to_code + ((currentSearch.to_date != '') ? currentSearch.from_code : ''), price: PRICES_VIEW.getPrice('ticket_price', 4), quantity: 1 }
277 ]
278 }
279 );
280} catch(e) {
281 console.error('Criteo', e);
282}