jQuery( document ).ready(function( $ ) { var referrer = document.referrer.split('/')[2]; var evented = 0; var href = window.location.href; if(evented == 0 && strstr(href, 'yclid=')) { $.cookie('jPhone', 'k_0', { expires: 30, path: '/' }); evented = 1;} if ($.cookie('jPhone') == 'k_0') { $('.ringo-kiev').html('044 225 80 12')} if(evented == 0 && strstr(href, 'gclid=')) { $.cookie('jPhone', 'k_1', { expires: 30, path: '/' }); evented = 1;} if ($.cookie('jPhone') == 'k_1') { $('.ringo-kiev').html('044 225 80 14')} if(evented == 0 && strstr(href, 'utm_source=yandex&utm_medium=cpc')) { $.cookie('jPhone', 'k_2', { expires: 30, path: '/' }); evented = 1;} if ($.cookie('jPhone') == 'k_2') { $('.ringo-kiev').html('044 225 80 12')} if(evented == 0 && strstr(href, 'utm_source=google&utm_medium=cpc')) { $.cookie('jPhone', 'k_3', { expires: 30, path: '/' }); evented = 1;} if ($.cookie('jPhone') == 'k_3') { $('.ringo-kiev').html('044 225 80 14')} if(evented == 0 && strstr(referrer, 'google.')) { $.cookie('jPhone', 'k_4', { expires: 30, path: '/' }); evented = 1;} if ($.cookie('jPhone') == 'k_4') { $('.ringo-kiev').html('044 225 80 14')} if(evented == 0 && strstr(referrer, 'yandex.')) { $.cookie('jPhone', 'k_5', { expires: 30, path: '/' }); evented = 1;} if ($.cookie('jPhone') == 'k_5') { $('.ringo-kiev').html('044 225 80 13')} }) function strstr (haystack, needle, bool) { // discuss at: http://phpjs.org/functions/strstr/ var pos = 0 haystack += '' pos = haystack.indexOf(needle) if (pos == -1) { return false } else { if (bool) { return haystack.substr(0, pos) } else { return haystack.slice(pos) } } }