|
26 | 26 | 'de': 'de|at|li',
|
27 | 27 | 'es': 'ar|bo|cl|co|cr|cu|do|ec|sv|gt|hn|mx|ni|pa|py|pr|es|uy|ve',
|
28 | 28 | 'fr': 'fr|ad|bj|bf|cf|cg|ga|gn|ml|mc|ne|sn|tg',
|
| 29 | + 'id': 'id', |
29 | 30 | 'it': 'it',
|
30 | 31 | 'ko': 'kr',
|
31 | 32 | 'pl': 'po',
|
|
48 | 49 | var loginid = localStorage.getItem('active_loginid');
|
49 | 50 | var client_info = JSON.parse(localStorage.getItem('client.accounts') || '{}')[loginid];
|
50 | 51 | var is_logged_in = client_info && client_info['token'];
|
51 |
| - window.location.href = (lang || 'en').toLowerCase() + '/' + (is_logged_in ? 'trading' : 'home') + '.html' + window.location.search; |
52 |
| - } |
53 |
| - function isDelayedRedirect() { |
54 |
| - if (isGtmApplicable() && !redirectTimeOut) { |
55 |
| - redirectTimeOut = setTimeout(redirect, 5000); |
56 |
| - } else { |
57 |
| - clearTimeout(redirectTimeOut); |
58 |
| - redirect(); |
59 |
| - } |
60 |
| - } |
61 |
| - function isGtmApplicable() { |
62 |
| - return /(www|staging)\.binary\.(com|me)/i.test(window.location.hostname); |
63 |
| - } |
64 |
| - function pushEvent() { |
65 |
| - if (isGtmApplicable()) { |
66 |
| - dataLayer.push({ |
67 |
| - 'event': 'page_load', |
68 |
| - 'eventCallback': function() { |
69 |
| - isDelayedRedirect(); |
70 |
| - } |
71 |
| - }); |
72 |
| - } else { |
73 |
| - isDelayedRedirect(); |
74 |
| - } |
| 52 | + |
| 53 | + var search = window.location.search ? window.location.search : ''; |
| 54 | + var has_external_referrer = document.referrer && !/\.binary\.(com|me)/.test(document.referrer); |
| 55 | + var has_utm_source = /utm_source/.test(search); |
| 56 | + var utm_source = has_external_referrer && !has_utm_source ? ((search ? '&' : '?') + 'utm_source=' + new URL(document.referrer).hostname) : ''; |
| 57 | + |
| 58 | + window.location.href = (lang || 'en').toLowerCase() + '/' + (is_logged_in ? 'trading' : 'home') + '.html' + search + utm_source; |
75 | 59 | }
|
76 | 60 |
|
77 | 61 | if (/^https:\/\/staging\.binary\.com\/translations\//i.test(window.location.href)) {
|
|
81 | 65 | localStorage.setItem('index_referrer', document.referrer);
|
82 | 66 | }
|
83 | 67 | lang = getCookieItem('language');
|
84 |
| - var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1'); |
85 |
| - ws.onopen = function(e) { |
86 |
| - ws.send(JSON.stringify({'website_status': '1'})); |
87 |
| - }; |
88 |
| - ws.onmessage = function(msg) { |
89 |
| - var response = JSON.parse(msg.data); |
90 |
| - if (response.msg_type === 'website_status') { |
91 |
| - if (!lang && !response.error && response.hasOwnProperty('website_status')) { |
92 |
| - lang = getLanguage(response.website_status.clients_country); |
| 68 | + if (lang) { |
| 69 | + redirect(); |
| 70 | + } else { |
| 71 | + var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1'); |
| 72 | + ws.onopen = function(e) { |
| 73 | + ws.send(JSON.stringify({'website_status': '1'})); |
| 74 | + }; |
| 75 | + ws.onmessage = function(msg) { |
| 76 | + var response = JSON.parse(msg.data); |
| 77 | + if (response.msg_type === 'website_status') { |
| 78 | + if (!response.error && response.hasOwnProperty('website_status')) { |
| 79 | + lang = getLanguage(response.website_status.clients_country); |
| 80 | + } |
| 81 | + ws.close(); |
| 82 | + redirect(); |
93 | 83 | }
|
94 |
| - ws.close(); |
95 |
| - pushEvent(); // we need website_status.clients_country |
96 |
| - } |
97 |
| - }; |
| 84 | + }; |
| 85 | + } |
98 | 86 | }
|
99 | 87 | </script>
|
100 | 88 | </head>
|
101 |
| - <body> |
102 |
| -<!-- Google Tag Manager --> |
103 |
| -<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-MZWFF7" |
104 |
| -height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> |
105 |
| -<script data-cfasync="false">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': |
106 |
| -new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], |
107 |
| -j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= |
108 |
| -'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); |
109 |
| -})(window,document,'script','dataLayer','GTM-MZWFF7');</script> |
110 |
| -<!-- End Google Tag Manager --> |
111 |
| - </body> |
112 | 89 | </html>
|
0 commit comments