%PDF- %PDF-
Direktori : /home/tradesc/www/relax/wp-content/cache/wpfc-minified/knavir6r/ |
Current File : /home/tradesc/www/relax/wp-content/cache/wpfc-minified/knavir6r/ho1c1.js |
(function(t){function e(e){return u?e.data("events"):t._data(e[0]).events}function n(t,n,r){var i=e(t),a=i[n];if(!u){var s=r?a.splice(a.delegateCount-1,1)[0]:a.pop();return a.splice(r?0:a.delegateCount||0,0,s),void 0}r?i.live.unshift(i.live.pop()):a.unshift(a.pop())}function r(e,r,i){var a=r.split(/\s+/);e.each(function(){for(var e=0;a.length>e;++e){var r=a[e].trim().match(/[^\.]+/i)[0];n(t(this),r,i)}})}function i(e){t.fn[e+"First"]=function(){var n=t.makeArray(arguments),i=n.shift();return i&&(t.fn[e].apply(this,arguments),r(this,i)),this}}var a=t.fn.jquery.split("."),s=parseInt(a[0]),f=parseInt(a[1]),u=1>s||1==s&&7>f;i("bind"),i("one"),t.fn.delegateFirst=function(){var e=t.makeArray(arguments),n=e[1];return n&&(e.splice(0,2),t.fn.delegate.apply(this,arguments),r(this,n,!0)),this},t.fn.liveFirst=function(){var e=t.makeArray(arguments);return e.unshift(this.selector),t.fn.delegateFirst.apply(t(document),e),this},u||(t.fn.onFirst=function(e,n){var i=t(this),a="string"==typeof n;if(t.fn.on.apply(i,arguments),"object"==typeof e)for(type in e)e.hasOwnProperty(type)&&r(i,type,a);else"string"==typeof e&&r(i,e,a);return i})})(jQuery); !function(e){var n=!1;if("function"==typeof define&&define.amd&&(define(e),n=!0),"object"==typeof exports&&(module.exports=e(),n=!0),!n){var o=window.Cookies,t=window.Cookies=e();t.noConflict=function(){return window.Cookies=o,t}}}(function(){function e(){for(var e=0,n={};e<arguments.length;e++){var o=arguments[e];for(var t in o)n[t]=o[t]}return n}function n(o){function t(n,r,i){var c;if("undefined"!=typeof document){if(arguments.length>1){if(i=e({path:"/"},t.defaults,i),"number"==typeof i.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}try{c=JSON.stringify(r),/^[\{\[]/.test(c)&&(r=c)}catch(e){}return r=o.write?o.write(r,n):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),n=encodeURIComponent(String(n)),n=n.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),n=n.replace(/[\(\)]/g,escape),document.cookie=[n,"=",r,i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}n||(c={});for(var p=document.cookie?document.cookie.split("; "):[],s=/(%[0-9A-Z]{2})+/g,d=0;d<p.length;d++){var f=p[d].split("="),u=f.slice(1).join("=");'"'===u.charAt(0)&&(u=u.slice(1,-1));try{var l=f[0].replace(s,decodeURIComponent);if(u=o.read?o.read(u,l):o(u,l)||u.replace(s,decodeURIComponent),this.json)try{u=JSON.parse(u)}catch(e){}if(n===l){c=u;break}n||(c[l]=u)}catch(e){}}return c}}return t.set=t,t.get=function(e){return t.call(t,e)},t.getJSON=function(){return t.apply({json:!0},[].slice.call(arguments))},t.defaults={},t.remove=function(n,o){t(n,"",e(o,{expires:-1}))},t.withConverter=n,t}return n(function(){})}); if(!Array.prototype.includes){ Object.defineProperty(Array.prototype, 'includes', { value: function (searchElement, fromIndex){ if(this==null){ throw new TypeError('"this" is null or not defined'); } var o=Object(this); var len=o.length >>> 0; if(len===0){ return false; } var n=fromIndex | 0; var k=Math.max(n >=0 ? n:len - Math.abs(n), 0); function sameValueZero(x, y){ return x===y||(typeof x==='number'&&typeof y==='number'&&isNaN(x)&&isNaN(y)); } while (k < len){ if(sameValueZero(o[k], searchElement)){ return true; } k++; } return false; }}); } !function ($, options){ if(options.debug){ console.log('PYS:', options); } var uniqueId={}; var dummyPinterest=function (){ return { isEnabled: function (){}, disable: function (){}, loadPixel: function (){}, fireEvent: function (name, data){ return false; }, onCommentEvent: function (){}, onDownloadEvent: function (params){}, onFormEvent: function (params){}, onWooAddToCartOnButtonEvent: function (product_id){}, onWooAddToCartOnSingleEvent: function (product_id, qty, is_variable, is_external, $form){}, onWooRemoveFromCartEvent: function (cart_item_hash){}, onEddAddToCartOnButtonEvent: function (download_id, price_index, qty){}, onEddRemoveFromCartEvent: function (item){}, onPageScroll: function (event){}, onTime: function (event){}, }}(); var dummyBing=function (){ return { isEnabled: function (){}, disable: function (){}, loadPixel: function (){}, fireEvent: function (name, data){ return false; }, onAdSenseEvent: function (){}, onClickEvent: function (params){}, onWatchVideo: function (params){}, onCommentEvent: function (){}, onFormEvent: function (params){}, onDownloadEvent: function (params){}, onWooAddToCartOnButtonEvent: function (product_id){}, onWooAddToCartOnSingleEvent: function (product_id, qty, is_variable, is_external, $form){}, onWooRemoveFromCartEvent: function (cart_item_hash){}, onWooAffiliateEvent: function (product_id){}, onWooPayPalEvent: function (){}, onEddAddToCartOnButtonEvent: function (download_id, price_index, qty){}, onEddRemoveFromCartEvent: function (item){}, onPageScroll: function (event){}, onTime: function (event){}, }}(); var Utils=function (options){ var Pinterest=dummyPinterest; var Bing=dummyBing; var gtag_loaded=false; let isNewSession=checkSession(); var utmTerms=['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content']; var utmId=['fbadid', 'gadid', 'padid', 'bingid']; function validateEmail(email){ var re=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function getDomain(url){ url=url.replace(/(https?:\/\/)?(www.)?/i, ''); if(url.indexOf('/')!==-1){ return url.split('/')[0]; } return url; } function loadPixels(){ if(!options.gdpr.all_disabled_by_api){ if(!options.gdpr.facebook_disabled_by_api){ Facebook.loadPixel(); } if(!options.gdpr.analytics_disabled_by_api){ Analytics.loadPixel(); } if(!options.gdpr.pinterest_disabled_by_api){ Pinterest.loadPixel(); } if(!options.gdpr.bing_disabled_by_api){ Bing.loadPixel(); }} if(options.gdpr.consent_magic_integration_enabled&&typeof CS_Data!=="undefined"){ if(typeof CS_Data.cs_google_analytics_consent_mode!=="undefined"&&CS_Data.cs_google_analytics_consent_mode==1){ Analytics.loadPixel(); }} } function checkSession(){ if(Cookies.get('pys_start_session')===undefined || Cookies.get('pys_session_limit')===undefined){ firstVisit=true; return true } return false } function getTrafficSource(){ try { let referrer=document.referrer.toString(), source; let direct=referrer.length===0; let internal=direct ? false:referrer.indexOf(options.siteUrl)===0; let external = !direct&&!internal; if(external===false){ source='direct'; }else{ source=referrer; } if(source!=='direct'){ return getDomain(source); }else{ return source; }} catch (e){ console.error(e); return 'direct'; }} function getQueryVars(){ try { var result={}, tmp=[]; window.location.search .substr(1) .split("&") .forEach(function (item){ tmp=item.split('='); if(tmp.length > 1){ result[tmp[0]]=tmp[1]; }}); return result; } catch (e){ console.error(e); return {};}} function getLandingPageValue(){ let name="pys_landing_page" if(options.visit_data_model==="last_visit"){ name="last_pys_landing_page" } if(Cookies.get(name)&&Cookies.get(name)!=="undefined"){ return Cookies.get(name); } else if(options.hasOwnProperty("tracking_analytics")&&options.tracking_analytics.TrafficLanding){ return options.tracking_analytics.TrafficLanding; }else{ return ""; }} function getTrafficSourceValue(){ let name="pysTrafficSource" if(options.visit_data_model==="last_visit"){ name="last_pysTrafficSource" } if(Cookies.get(name)&&Cookies.get(name)!=="undefined"){ return Cookies.get(name); } else if(options.hasOwnProperty("tracking_analytics")&&options.tracking_analytics.TrafficSource){ return options.tracking_analytics.TrafficSource; }else{ return ""; }} function getUTMId(useLast=false){ try { let cookiePrefix='pys_' let terms=[]; if(useLast){ cookiePrefix='last_pys_' } $.each(utmId, function (index, name){ if(Cookies.get(cookiePrefix + name)){ terms[name]=Cookies.get(cookiePrefix + name) } else if(options.hasOwnProperty("tracking_analytics")&&options.tracking_analytics.TrafficUtmsId[name]){ terms[name]=filterEmails(options.tracking_analytics.TrafficUtmsId[name]) }}); return terms; } catch (e){ console.error(e); return []; }} function getUTMs(useLast=false){ try { let cookiePrefix='pys_' if(useLast){ cookiePrefix='last_pys_' } let terms=[]; $.each(utmTerms, function (index, name){ if(Cookies.get(cookiePrefix + name)){ let value=Cookies.get(cookiePrefix + name); terms[name]=filterEmails(value); } else if(options.hasOwnProperty("tracking_analytics")&&options.tracking_analytics.TrafficUtms[name]){ terms[name]=filterEmails(options.tracking_analytics.TrafficUtms[name]) }}); return terms; } catch (e){ console.error(e); return []; }} function getDateTime(){ var dateTime=new Array(); var date=new Date(), days=['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], months=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ], hours=['00-01', '01-02', '02-03', '03-04', '04-05', '05-06', '06-07', '07-08', '08-09', '09-10', '10-11', '11-12', '12-13', '13-14', '14-15', '15-16', '16-17', '17-18', '18-19', '19-20', '20-21', '21-22', '22-23', '23-24' ]; dateTime.push(hours[date.getHours()]); dateTime.push(days[date.getDay()]); dateTime.push(months[date.getMonth()]); return dateTime; } function filterEmails(value){ return validateEmail(value) ? undefined:value; } return { PRODUCT_SIMPLE:0, PRODUCT_VARIABLE:1, PRODUCT_BUNDLE:2, PRODUCT_GROUPED:3, utmTerms:utmTerms, utmId:utmId, fireEventForAllPixel:function(functionName,events){ if(events.hasOwnProperty(Facebook.tag())) Facebook[functionName](events[Facebook.tag()]); if(events.hasOwnProperty(Analytics.tag())) Analytics[functionName](events[Analytics.tag()]); if(events.hasOwnProperty(Pinterest.tag())) Pinterest[functionName](events[Pinterest.tag()]); if(events.hasOwnProperty(Bing.tag())) Bing[functionName](events[Bing.tag()]); }, setupPinterestObject: function (){ Pinterest=window.pys.Pinterest||Pinterest; return Pinterest; }, setupBingObject: function (){ Bing=window.pys.Bing||Bing; return Bing; }, copyProperties: function (from, to){ for (var key in from){ if("function"==typeof from[key]){ continue; } to[key]=from[key]; } return to; }, manageCookies: function (){ if(options.gdpr.cookiebot_integration_enabled&&typeof Cookiebot!=='undefined'){ if(Cookiebot.consented===false&&!Cookiebot.consent['marketing']&&!Cookiebot.consent['statistics']){ return; }} let cm_consent_not_expressed=false; if(options.gdpr.consent_magic_integration_enabled&&window.CS_Data!==undefined&&window.CS_Data.cs_refresh_after_consent==1){ if(Cookies.get('cs_viewed_cookie_policy')===undefined){ cm_consent_not_expressed=true; }} if(!cm_consent_not_expressed&&isNewSession&&!options.cookie.disabled_all_cookie&&!options.cookie.disabled_start_session_cookie){ let duration=options.last_visit_duration * 60000 var now=new Date(); now.setTime(now.getTime() + duration); Cookies.set('pys_session_limit', true,{ expires: now }) Cookies.set('pys_start_session', true); } if(options.gdpr.ajax_enabled&&!options.gdpr.consent_magic_integration_enabled){ $.get({ url: options.ajaxUrl, dataType: 'json', data: { action: 'pys_get_gdpr_filters_values' }, success: function (res){ if(res.success){ options.gdpr.all_disabled_by_api=res.data.all_disabled_by_api; options.gdpr.facebook_disabled_by_api=res.data.facebook_disabled_by_api; options.gdpr.tiktok_disabled_by_api=res.data.tiktok_disabled_by_api; options.gdpr.analytics_disabled_by_api=res.data.analytics_disabled_by_api; options.gdpr.google_ads_disabled_by_api=res.data.google_ads_disabled_by_api; options.gdpr.pinterest_disabled_by_api=res.data.pinterest_disabled_by_api; options.gdpr.bing_disabled_by_api=res.data.bing_disabled_by_api; options.cookie.externalID_disabled_by_api=res.data.externalID_disabled_by_api; options.cookie.disabled_all_cookie=res.data.disabled_all_cookie; options.cookie.disabled_advanced_form_data_cookie=res.data.disabled_advanced_form_data_cookie; options.cookie.disabled_landing_page_cookie=res.data.disabled_landing_page_cookie; options.cookie.disabled_first_visit_cookie=res.data.disabled_first_visit_cookie; options.cookie.disabled_trafficsource_cookie=res.data.disabled_trafficsource_cookie; options.cookie.disabled_utmTerms_cookie=res.data.disabled_utmTerms_cookie; options.cookie.disabled_utmId_cookie=res.data.disabled_utmId_cookie; }} }); } if(options.ajaxForServerEvent&&!Cookies.get('pbid')&&Facebook.isEnabled()){ jQuery.ajax({ url: options.ajaxUrl, dataType: 'json', data: { action: 'pys_get_pbid' }, success: function (res){ if(res.data&&res.data.pbid!=false&&options.send_external_id){ if(!(options.cookie.disabled_all_cookie||options.cookie.externalID_disabled_by_api)){ var expires=parseInt(options.external_id_expire||180); Cookies.set('pbid', res.data.pbid, { expires: expires, path: '/' }); } if(options.hasOwnProperty('facebook')){ options.facebook.advancedMatching={ ...options.facebook.advancedMatching, external_id: res.data.pbid };}} }}); }else if(Cookies.get('pbid')&&Facebook.isEnabled()){ if(Facebook.advancedMatching()&&Facebook.advancedMatching().external_id&&!(options.cookie.disabled_all_cookie||options.cookie.externalID_disabled_by_api)){ let expires=parseInt(options.external_id_expire||180); Cookies.set('pbid', Facebook.advancedMatching().external_id, { expires: expires, path: '/' }); }} let expires=parseInt(options.cookie_duration); let queryVars=getQueryVars(); let landing=window.location.href.split('?')[0]; try { if(Cookies.get('pys_first_visit')===undefined&&(!options.cookie.disabled_all_cookie)){ if(!options.cookie.disabled_first_visit_cookie){ Cookies.set('pys_first_visit', true, { expires: expires }); }else{ Cookies.remove('pys_first_visit') } if(!options.cookie.disabled_trafficsource_cookie){ Cookies.set('pysTrafficSource', getTrafficSource(), { expires: expires }); }else{ Cookies.remove('pysTrafficSource') } if(!options.cookie.disabled_landing_page_cookie){ Cookies.set('pys_landing_page',landing,{ expires: expires }); }else{ Cookies.remove('pys_landing_page') } if(!options.cookie.disabled_utmTerms_cookie){ $.each(utmTerms, function (index, name){ if(queryVars.hasOwnProperty(name)){ Cookies.set('pys_' + name, queryVars[name], { expires: expires }); }else{ Cookies.remove('pys_' + name) }}); }else{ $.each(utmTerms, function (index, name){ Cookies.remove('pys_' + name) }); } if(!options.cookie.disabled_utmId_cookie){ $.each(utmId,function(index,name){ if(queryVars.hasOwnProperty(name)){ Cookies.set('pys_' + name, queryVars[name], { expires: expires }); }else{ Cookies.remove('pys_' + name) }}) }else{ $.each(utmId, function (index, name){ Cookies.remove('pys_' + name) }); }} if(isNewSession&&(!options.cookie.disabled_all_cookie)){ if(!options.cookie.disabled_trafficsource_cookie){ Cookies.set('last_pysTrafficSource', getTrafficSource(), { expires: expires }); }else{ Cookies.remove('last_pysTrafficSource') } if(!options.cookie.disabled_landing_page_cookie){ Cookies.set('last_pys_landing_page',landing,{ expires: expires }); }else{ Cookies.remove('last_pys_landing_page') } if(!options.cookie.disabled_utmTerms_cookie){ $.each(utmTerms, function (index, name){ if(queryVars.hasOwnProperty(name)){ Cookies.set('last_pys_' + name, queryVars[name], { expires: expires }); }else{ Cookies.remove('last_pys_' + name) }}); }else{ $.each(utmTerms, function (index, name){ Cookies.remove('last_pys_' + name) }); } if(!options.cookie.disabled_utmId_cookie){ $.each(utmId,function(index,name){ if(queryVars.hasOwnProperty(name)){ Cookies.set('last_pys_' + name, queryVars[name], { expires: expires }); }else{ Cookies.remove('last_pys_' + name) }}) }else{ $.each(utmId, function (index, name){ Cookies.remove('last_pys_' + name) }); }} if(options.cookie.disabled_start_session_cookie){ Cookies.remove('pys_start_session') Cookies.remove('pys_session_limit') } if(options.cookie.disabled_all_cookie){ Cookies.remove('pys_first_visit') Cookies.remove('pysTrafficSource') Cookies.remove('pys_landing_page') Cookies.remove('last_pys_landing_page') Cookies.remove('last_pysTrafficSource') Cookies.remove('pys_start_session') Cookies.remove('pys_session_limit') $.each(Utils.utmTerms, function (index, name){ Cookies.remove('pys_' + name) }); $.each(Utils.utmId,function(index,name){ Cookies.remove('pys_' + name) }) $.each(Utils.utmTerms, function (index, name){ Cookies.remove('last_pys_' + name) }); $.each(Utils.utmId,function(index,name){ Cookies.remove('last_pys_' + name) }); }} catch (e){ console.error(e); }}, generateUniqueId:function (event){ if(event.eventID.length==0||(event.type=="static"&&options.ajaxForServerStaticEvent)||(event.type!=="static"&&options.ajaxForServerEvent)){ let idKey=event.hasOwnProperty('custom_event_post_id') ? event.custom_event_post_id:event.e_id; if(!uniqueId.hasOwnProperty(idKey)){ uniqueId[idKey]=pys_generate_token(); } return uniqueId[idKey]; } else if(event.eventID.length!==0){ return event.eventID; }}, sendServerAjaxRequest:function(url, data){ jQuery.ajax({ type: 'POST', url: url, data: data, headers: { 'Cache-Control': 'no-cache' }, success: function (){}, }); }, clone: function(obj){ var copy; if(null==obj||"object"!=typeof obj) return obj; if(obj instanceof Date){ copy=new Date(); copy.setTime(obj.getTime()); return copy; } if(obj instanceof Array){ copy=[]; for (var i=0, len=obj.length; i < len; i++){ if("function"==typeof obj[i]){ continue; } copy[i]=Utils.clone(obj[i]); } return copy; } if(obj instanceof Object){ copy={}; for (var attr in obj){ if(obj.hasOwnProperty(attr)){ if("function"==typeof obj[attr]){ continue; } copy[attr]=Utils.clone(obj[attr]); }} return copy; } return obj; }, getTagsAsArray: function (tag){ return [].slice.call(document.getElementsByTagName(tag)); }, getRequestParams: function (){ return []; }, setupMouseOverClickEvents: function (eventId, triggers){ document.addEventListener('mouseover', function(event){ var matchedElements=Array.from(document.querySelectorAll(triggers)); if(matchedElements.includes(event.target)){ if(event.target.classList.contains('pys-mouse-over-' + eventId)){ return true; }else{ event.target.classList.add('pys-mouse-over-' + eventId); } Utils.fireTriggerEvent(eventId); }}); }, setupCSSClickEvents: function (eventId, triggers){ document.addEventListener('click', function(event){ var matchedElements=Array.from(document.querySelectorAll(triggers)); if(matchedElements.includes(event.target)){ console.log(event.target) Utils.fireTriggerEvent(eventId); }}, true); }, setupURLClickEvents: function (){ $('a[data-pys-event-id]').onFirst('click', function (evt){ $(this).attr('data-pys-event-id').split(',').forEach(function (eventId){ eventId=parseInt(eventId); if(isNaN(eventId)===false){ Utils.fireTriggerEvent(eventId); }}); }); }, setupScrollPosEvents: function (eventId, triggers){ var scrollPosThresholds={}, docHeight=$(document).height() - $(window).height(); $.each(triggers, function (index, scrollPos){ scrollPos=docHeight * scrollPos / 100; scrollPos=Math.round(scrollPos); scrollPosThresholds[scrollPos]=eventId; }); $(document).on("scroll",function (){ var scrollPos=$(window).scrollTop(); $.each(scrollPosThresholds, function (threshold, eventId){ if(scrollPos <=threshold){ return true; } if(eventId===null){ return true; }else{ scrollPosThresholds[threshold]=null; } Utils.fireTriggerEvent(eventId); }); }); }, setupCommentEvents:function (eventId,triggers){ $('form.comment-form').on("submit",function (){ Utils.fireTriggerEvent(eventId); }); }, fireTriggerEvent: function (eventId){ if(!options.triggerEvents.hasOwnProperty(eventId)){ return; } var event={}; var events=options.triggerEvents[eventId]; if(events.hasOwnProperty('facebook')){ event=events.facebook; Facebook.fireEvent(event.name, event); } if(events.hasOwnProperty('ga')){ event=events.ga; Analytics.fireEvent(event.name, event); } if(events.hasOwnProperty('pinterest')){ event=events.pinterest; Pinterest.fireEvent(event.name, event); } if(events.hasOwnProperty('bing')){ event=events.bing; Bing.fireEvent(event.name, event); }}, fireStaticEvents: function (pixel){ if(options.staticEvents.hasOwnProperty(pixel)){ $.each(options.staticEvents[pixel], function (eventName, events){ $.each(events, function (index, eventData){ eventData.fired=eventData.fired||false; if(!eventData.fired){ var fired=false; if('facebook'===pixel){ fired=Facebook.fireEvent(eventData.name, eventData); }else if('ga'===pixel){ fired=Analytics.fireEvent(eventData.name, eventData); }else if('pinterest'===pixel){ fired=Pinterest.fireEvent(eventData.name, eventData); }else if('bing'===pixel){ fired=Bing.fireEvent(eventData.name, eventData); } eventData.fired=fired; }}); }); }}, loadGoogleTag: function (id){ if(!gtag_loaded){ (function (window, document, src){ var a=document.createElement('script'), m=document.getElementsByTagName('script')[0]; a.async=1; a.src=src; m.parentNode.insertBefore(a, m); })(window, document, '//www.googletagmanager.com/gtag/js?id=' + id); window.dataLayer=window.dataLayer||[]; window.gtag=window.gtag||function gtag(){ dataLayer.push(arguments); }; if(options.google_consent_mode){ let data={}; data[ 'analytics_storage' ]=options.gdpr.analytics_storage.enabled ? options.gdpr.analytics_storage.value:'granted'; data[ 'ad_storage' ]=options.gdpr.ad_storage.enabled ? options.gdpr.ad_storage.value:'granted'; data[ 'ad_user_data' ]=options.gdpr.ad_user_data.enabled ? options.gdpr.ad_user_data.value:'granted'; data[ 'ad_personalization' ]=options.gdpr.ad_personalization.enabled ? options.gdpr.ad_personalization.value:'granted'; gtag('consent', 'default', data); } gtag('js', new Date()); gtag_loaded=true; }}, loadPixels: function (){ if(options.gdpr.ajax_enabled&&!options.gdpr.consent_magic_integration_enabled){ $.get({ url: options.ajaxUrl, dataType: 'json', data: { action: 'pys_get_gdpr_filters_values' }, success: function (res){ if(res.success){ options.gdpr.all_disabled_by_api=res.data.all_disabled_by_api; options.gdpr.facebook_disabled_by_api=res.data.facebook_disabled_by_api; options.gdpr.analytics_disabled_by_api=res.data.analytics_disabled_by_api; options.gdpr.google_ads_disabled_by_api=res.data.google_ads_disabled_by_api; options.gdpr.pinterest_disabled_by_api=res.data.pinterest_disabled_by_api; options.gdpr.bing_disabled_by_api=res.data.bing_disabled_by_api; options.cookie.externalID_disabled_by_api=res.data.externalID_disabled_by_api; options.cookie.disabled_all_cookie=res.data.disabled_all_cookie; options.cookie.disabled_advanced_form_data_cookie=res.data.disabled_advanced_form_data_cookie; options.cookie.disabled_landing_page_cookie=res.data.disabled_landing_page_cookie; options.cookie.disabled_first_visit_cookie=res.data.disabled_first_visit_cookie; options.cookie.disabled_trafficsource_cookie=res.data.disabled_trafficsource_cookie; options.cookie.disabled_utmTerms_cookie=res.data.disabled_utmTerms_cookie; options.cookie.disabled_utmId_cookie=res.data.disabled_utmId_cookie; } loadPixels(); }}); }else{ loadPixels(); }}, consentGiven: function (pixel){ if(options.gdpr.consent_magic_integration_enabled&&typeof CS_Data!=="undefined"){ var test_prefix=CS_Data.test_prefix; if(( typeof CS_Data.cs_google_consent_mode_enabled!=="undefined"&&CS_Data.cs_google_consent_mode_enabled==1)&&(pixel=='analytics'||pixel=='google_ads')){ if(CS_Data.cs_cache_enabled==0||(CS_Data.cs_cache_enabled==1&&window.CS_Cache&&window.CS_Cache.check_status)){ return true; }else{ return false; }} if(pixel=='facebook'&&(CS_Data.cs_script_cat.facebook==0||CS_Data.cs_script_cat.facebook==CS_Data.cs_necessary_cat_id)){ return true; }else if(pixel=='bing'&&(CS_Data.cs_script_cat.bing==0||CS_Data.cs_script_cat.bing==CS_Data.cs_necessary_cat_id)){ return true; }else if(pixel=='analytics'&&(CS_Data.cs_script_cat.analytics==0||CS_Data.cs_script_cat.analytics==CS_Data.cs_necessary_cat_id)){ return true; }else if(pixel=='google_ads'&&(CS_Data.cs_script_cat.gads==0||CS_Data.cs_script_cat.gads==CS_Data.cs_necessary_cat_id)){ return true; }else if(pixel=='pinterest'&&(CS_Data.cs_script_cat.pinterest==0||CS_Data.cs_script_cat.pinterest==CS_Data.cs_necessary_cat_id)){ return true; }else if(pixel=='tiktok'&&(CS_Data.cs_script_cat.tiktok==0||CS_Data.cs_script_cat.tiktok==CS_Data.cs_necessary_cat_id)){ return true; } var substring="cs_enabled_cookie_term"; var theCookies=document.cookie.split(';'); for(var i=1; i <=theCookies.length; i++){ if(theCookies[ i - 1 ].indexOf(substring)!==-1){ var categoryCookie=theCookies[ i - 1 ].replace('cs_enabled_cookie_term' + test_prefix + '_', ''); categoryCookie=Number(categoryCookie.replace(/\D+/g, "")); var cs_cookie_val=Cookies.get('cs_enabled_cookie_term' + test_prefix + '_' + categoryCookie); if(categoryCookie===CS_Data.cs_script_cat.facebook&&pixel=='facebook'){ return cs_cookie_val=='yes'; }else if(categoryCookie===CS_Data.cs_script_cat.bing&&pixel=='bing'){ return cs_cookie_val=='yes'; }else if(categoryCookie===CS_Data.cs_script_cat.analytics&&pixel=='analytics'){ return cs_cookie_val=='yes'; }else if(categoryCookie===CS_Data.cs_script_cat.gads&&pixel=='google_ads'){ return cs_cookie_val=='yes'; }else if(categoryCookie===CS_Data.cs_script_cat.pinterest&&pixel=='pinterest'){ return cs_cookie_val=='yes'; }else if(categoryCookie===CS_Data.cs_script_cat.tiktok&&pixel=='tiktok'){ return cs_cookie_val=='yes'; }} } return false; } if(options.gdpr.real_cookie_banner_integration_enabled){ var consentApi=window.consentApi; if(consentApi){ switch (pixel){ case "analytics": return consentApi.consentSync("http", "_ga", "*").cookieOptIn; case "facebook": return consentApi.consentSync("http", "_fbp", "*").cookieOptIn; case "pinterest": return consentApi.consentSync("http", "_pinterest_sess", ".pinterest.com").cookieOptIn; default: return true; }} } if(options.gdpr.cookiebot_integration_enabled&&typeof Cookiebot!=='undefined'){ var cookiebot_consent_category=options.gdpr['cookiebot_' + pixel + '_consent_category']; if(options.gdpr[pixel + '_prior_consent_enabled']){ if(Cookiebot.consented===true||Cookiebot.consent[cookiebot_consent_category]){ return true; }}else{ if(Cookiebot.consent[cookiebot_consent_category]){ return true; }} return false; } if(options.gdpr.cookie_notice_integration_enabled&&typeof cnArgs!=='undefined'){ var cn_cookie=Cookies.get(cnArgs.cookieName); if(options.gdpr[pixel + '_prior_consent_enabled']){ if(typeof cn_cookie==='undefined'||cn_cookie==='true'){ return true; }}else{ if(cn_cookie==='true'){ return true; }} return false; } if(options.gdpr.cookie_law_info_integration_enabled){ var cli_cookie=Cookies.get('cookieyes-consent') ?? Cookies.get('viewed_cookie_policy'); if(options.gdpr[pixel + '_prior_consent_enabled']){ if(typeof cli_cookie==='undefined') return true; if(cli_cookie&&cli_cookie===Cookies.get('cookieyes-consent')){ if(getCookieYes('analytics')==='yes'){ return true; }}else if(cli_cookie&&cli_cookie===Cookies.get('viewed_cookie_policy')){ if(Cookies.get('viewed_cookie_policy')==='yes'){ return true; }} }else{ if(cli_cookie&&cli_cookie===Cookies.get('cookieyes-consent')){ if(getCookieYes('analytics')==='yes'){ return true; }}else if(cli_cookie&&cli_cookie===Cookies.get('viewed_cookie_policy')){ if(Cookies.get('viewed_cookie_policy')==='yes'){ return true; }} } return false; } return true; }, setupGdprCallbacks: function (){ if(options.gdpr.consent_magic_integration_enabled&&typeof CS_Data!=="undefined"){ var test_prefix=CS_Data.test_prefix, cs_refresh_after_consent=false, substring="cs_enabled_cookie_term"; if(CS_Data.cs_refresh_after_consent==1){ cs_refresh_after_consent=CS_Data.cs_refresh_after_consent; } if(!cs_refresh_after_consent){ var theCookies=document.cookie.split(';'); for (var i=1 ; i <=theCookies.length; i++){ if(theCookies[i-1].indexOf(substring)!==-1){ var categoryCookie=theCookies[i-1].replace('cs_enabled_cookie_term'+test_prefix+'_',''); categoryCookie=Number(categoryCookie.replace(/\D+/g,"")); var cs_cookie_val=Cookies.get('cs_enabled_cookie_term'+test_prefix+'_'+categoryCookie); if(cs_cookie_val=='yes'){ if(categoryCookie===CS_Data.cs_script_cat.facebook){ Facebook.loadPixel(); } if(categoryCookie===CS_Data.cs_script_cat.bing){ Bing.loadPixel(); } if(categoryCookie===CS_Data.cs_script_cat.analytics||(typeof CS_Data.cs_google_analytics_consent_mode!=="undefined"&&CS_Data.cs_google_analytics_consent_mode==1)){ Analytics.loadPixel(); } if(categoryCookie===CS_Data.cs_script_cat.pinterest){ Pinterest.loadPixel(); }}else{ if(categoryCookie===CS_Data.cs_script_cat.facebook){ Facebook.disable(); } if(categoryCookie===CS_Data.cs_script_cat.bing){ Bing.disable(); } if(categoryCookie===CS_Data.cs_script_cat.analytics&&(typeof CS_Data.cs_google_analytics_consent_mode=="undefined"||CS_Data.cs_google_analytics_consent_mode==0)){ Analytics.disable(); } if(categoryCookie===CS_Data.cs_script_cat.pinterest){ Pinterest.disable(); }} if(Cookies.get('cs_enabled_advanced_matching')=='yes'){ Facebook.loadPixel(); }} } $(document).on('click','.cs_action_btn',function(e){ e.preventDefault(); var elm=$(this), button_action=elm.attr('data-cs_action'); if(button_action==='allow_all'){ Facebook.loadPixel(); Bing.loadPixel(); Analytics.loadPixel(); Pinterest.loadPixel(); }else if(button_action==='disable_all'){ Facebook.disable(); Bing.disable(); if(CS_Data.cs_google_analytics_consent_mode==0||typeof CS_Data.cs_google_analytics_consent_mode=="undefined"){ Analytics.disable(); } Pinterest.disable(); }}); }} if(options.gdpr.real_cookie_banner_integration_enabled){ var consentApi=window.consentApi; if(consentApi){ consentApi.consent("http", "_ga", "*") .then(Analytics.loadPixel.bind(Analytics), Analytics.disable.bind(Analytics)); consentApi.consent("http", "_fbp", "*") .then(Facebook.loadPixel.bind(Facebook), Facebook.disable.bind(Facebook)); consentApi.consent("http", "_pinterest_sess", ".pinterest.com") .then(Pinterest.loadPixel.bind(Pinterest), Pinterest.disable.bind(Pinterest)); consentApi.consent("http", "_uetsid", "*") .then(Bing.loadPixel.bind(Bing), Bing.disable.bind(Bing)); }} if(options.gdpr.cookiebot_integration_enabled&&typeof Cookiebot!=='undefined'){ window.addEventListener("CookiebotOnConsentReady", function(){ Utils.manageCookies(); if(Cookiebot.consent.marketing){ Facebook.loadPixel(); Bing.loadPixel(); Pinterest.loadPixel(); } if(Cookiebot.consent.statistics){ Analytics.loadPixel(); } if(!Cookiebot.consent.marketing){ Facebook.disable(); Pinterest.disable(); Bing.disable() } if(!Cookiebot.consent.statistics){ Analytics.disable(); }}); } if(options.gdpr.cookie_notice_integration_enabled){ $(document).onFirst('click', '.cn-set-cookie', function (){ if($(this).data('cookie-set')==='accept'){ Facebook.loadPixel(); Analytics.loadPixel(); Pinterest.loadPixel(); Bing.loadPixel(); }else{ Facebook.disable(); Analytics.disable(); Pinterest.disable(); Bing.disable(); }}); $(document).onFirst('click', '.cn-revoke-cookie', function (){ Facebook.disable(); Analytics.disable(); Pinterest.disable(); Bing.disable(); }); } if(options.gdpr.cookie_law_info_integration_enabled){ $(document).onFirst('click', '#wt-cli-accept-all-btn,#cookie_action_close_header, .cky-btn-accept', function (){ setTimeout(function (){ var cli_cookie=Cookies.get('cookieyes-consent') ?? Cookies.get('viewed_cookie_policy'); if(typeof cli_cookie!=='undefined'){ if(cli_cookie===Cookies.get('cookieyes-consent')&&getCookieYes('analytics')=='yes'){ Utils.manageCookies(); }else if(cli_cookie===Cookies.get('viewed_cookie_policy')&&cli_cookie=='yes'){ Utils.manageCookies(); }} },1000) Facebook.loadPixel(); Analytics.loadPixel(); Pinterest.loadPixel(); Bing.loadPixel(); }); $(document).onFirst('click', '#cookie_action_close_header_reject, .cky-btn-reject', function (){ Facebook.disable(); Analytics.disable(); Pinterest.disable(); Bing.disable(); }); }}, getLinkExtension: function (link){ link=link.substring(0, (link.indexOf("#")===-1) ? link.length:link.indexOf("#")); link=link.substring(0, (link.indexOf("?")===-1) ? link.length:link.indexOf("?")); link=link.substring(link.lastIndexOf("/") + 1, link.length); if(link.length > 0&&link.indexOf('.')!==-1){ link=link.substring(link.indexOf(".") + 1); return link; }else{ return ""; }}, getLinkFilename: function (link){ link=link.substring(0, (link.indexOf("#")===-1) ? link.length:link.indexOf("#")); link=link.substring(0, (link.indexOf("?")===-1) ? link.length:link.indexOf("?")); link=link.substring(link.lastIndexOf("/") + 1, link.length); if(link.length > 0&&link.indexOf('.')!==-1){ return link; }else{ return ""; }}, isCheckoutPage: function (){ return $('body').hasClass('woocommerce-checkout')||document.querySelector('.woocommerce-checkout') || $('body').hasClass('edd-checkout'); }, addCheckoutFields:function(){ var utm=""; var utms=getUTMs() $.each(utmTerms, function (index, name){ if(index > 0){ utm+="|"; } utm+=name+":"+utms[name]; }); var utmIdList=""; var utmsIds=getUTMId() $.each(utmId, function (index, name){ if(index > 0){ utmIdList+="|"; } utmIdList+=name+":"+utmsIds[name]; }); var utmIdListLast=""; var utmsIdsLast=getUTMId(true) $.each(utmId, function (index, name){ if(index > 0){ utmIdListLast+="|"; } utmIdListLast+=name+":"+utmsIdsLast[name]; }); var utmLast=""; var utmsLast=getUTMs(true) $.each(utmTerms, function (index, name){ if(index > 0){ utmLast+="|"; } utmLast+=name+":"+utmsLast[name]; }); var dateTime=getDateTime(); var landing=getLandingPageValue(); var lastLanding=getLandingPageValue(); var trafic=getTrafficSourceValue(); var lastTrafic=getTrafficSourceValue(); var $form=null; if($('body').hasClass('woocommerce-checkout')){ $form=$("form.woocommerce-checkout"); }else{ $form=$("#edd_purchase_form"); } var inputs={'pys_utm':utm, 'pys_utm_id':utmIdList, 'pys_browser_time':dateTime.join("|"), 'pys_landing':landing, 'pys_source':trafic, 'pys_order_type': $(".wcf-optin-form").length > 0 ? "wcf-optin":"normal", 'last_pys_landing':lastLanding, 'last_pys_source':lastTrafic, 'last_pys_utm':utmLast, 'last_pys_utm_id':utmIdListLast, } Object.keys(inputs).forEach(function(key,index){ $form.append("<input type='hidden' name='"+key+"' value='"+inputs[key]+"' /> "); }); }, getAdvancedFormData: function (){ let dataStr=Cookies.get("pys_advanced_form_data"); if(dataStr===undefined){ return {'first_name':"",'last_name':"",'email':"",'phone':""};}else{ return JSON.parse(dataStr); }} };}(options); var Facebook=function (options){ var defaultEventTypes=[ 'PageView', 'ViewContent', 'Search', 'AddToCart', 'AddToWishlist', 'InitiateCheckout', 'AddPaymentInfo', 'Purchase', 'Lead', 'Subscribe', 'CustomizeProduct', 'FindLocation', 'StartTrial', 'SubmitApplication', 'Schedule', 'Contact', 'Donate' ]; var initialized=false; var genereateFbp=function (){ return !Cookies.get('_fbp') ? 'fb.1.'+Date.now()+'.'+Math.floor(1000000000 + Math.random() * 9000000000):Cookies.get('_fbp'); }; var genereateFbc=function (){ return getUrlParameter('fbclid') ? 'fb.1.'+Date.now()+'.'+getUrlParameter('fbclid'):'' }; var isApiDisabled=options.gdpr.all_disabled_by_api || options.gdpr.facebook_disabled_by_api || options.gdpr.cookiebot_integration_enabled || options.gdpr.consent_magic_integration_enabled || options.gdpr.cookie_notice_integration_enabled || options.gdpr.cookie_law_info_integration_enabled; function sendFbServerEvent(allData,name,params){ let eventId=null; if(options.facebook.serverApiEnabled){ if(allData.e_id==="woo_remove_from_cart"){ Facebook.updateEventId(allData.name); allData.eventID=Facebook.getEventId(allData.name); }else{ allData.eventID=Utils.generateUniqueId(allData); if(Cookies.get('_fbp')){ params._fbp=Cookies.get('_fbp'); } if(Cookies.get('_fbc')){ params._fbc=Cookies.get('_fbc'); } if(options.ajaxForServerEvent||isApiDisabled){ var json={ action: 'pys_api_event', pixel: 'facebook', event: name, data:params, ids:options.facebook.pixelIds, eventID:allData.eventID, url:window.location.href, ajax_event:options.ajax_event }; if(allData.hasOwnProperty('woo_order')){ json['woo_order']=allData.woo_order; } if(allData.hasOwnProperty('edd_order')){ json['edd_order']=allData.edd_order; } if(allData.e_id==="automatic_event_internal_link"||allData.e_id==="automatic_event_outbound_link"){ setTimeout(()=> Utils.sendServerAjaxRequest(options.ajaxUrl, json), 500); }else if(allData.type!='static'){ Utils.sendServerAjaxRequest(options.ajaxUrl, json); } if(allData.type=='static'&&options.ajaxForServerStaticEvent){ Utils.sendServerAjaxRequest(options.ajaxUrl, json); }} } delete params._fbp; delete params._fbc; eventId=allData.eventID } return eventId; } function fireEvent(name, allData){ if(typeof window.pys_event_data_filter==="function"&&window.pys_disable_event_filter(name,'facebook')){ return; } var actionType=defaultEventTypes.includes(name) ? 'track':'trackCustom'; var data=allData.params; var params={}; var arg={}; Utils.copyProperties(data, params); let eventId=sendFbServerEvent(allData,name,params) if("hCR"===name){ return; } if(options.debug){ console.log('[Facebook] ' + name, params,"eventID",eventId); } if(eventId!=null){ arg.eventID=eventId; } fbq(actionType, name, params, arg); } return { tag: function(){ return "facebook"; }, isEnabled: function (){ return options.hasOwnProperty('facebook'); }, disable: function (){ initialized=false; }, advancedMatching: function (){ if(options.facebook.advancedMatchingEnabled){ let advancedMatchingForm=Utils.getAdvancedFormData(); let advancedMatching={}; if(Object.keys(options.facebook.advancedMatching).length > 0){ advancedMatching=options.facebook.advancedMatching; } if(!advancedMatching.hasOwnProperty("em") && advancedMatchingForm.hasOwnProperty("email")&&advancedMatchingForm["email"].length > 0){ advancedMatching["em"]=advancedMatchingForm["email"]; } if(!advancedMatching.hasOwnProperty("ph") && advancedMatchingForm.hasOwnProperty("phone")&&advancedMatchingForm["phone"].length > 0){ advancedMatching["ph"]=advancedMatchingForm["phone"]; } if(!advancedMatching.hasOwnProperty("fn") && advancedMatchingForm.hasOwnProperty("first_name")&&advancedMatchingForm["first_name"].length > 0){ advancedMatching["fn"]=advancedMatchingForm["first_name"]; } if(!advancedMatching.hasOwnProperty("ln") && advancedMatchingForm.hasOwnProperty("last_name")&&advancedMatchingForm["last_name"].length > 0){ advancedMatching["ln"]=advancedMatchingForm["last_name"]; } if(!advancedMatching.hasOwnProperty("external_id")){ if(Cookies.get('pbid')||(options.hasOwnProperty('pbid')&&options.pbid)){ advancedMatching["external_id"]=Cookies.get('pbid') ? Cookies.get('pbid'):options.pbid; }} else if(advancedMatching.external_id!=Cookies.get('pbid')){ advancedMatching["external_id"]=Cookies.get('pbid') ? Cookies.get('pbid'):advancedMatching.external_id; } if(Object.keys(advancedMatching).length > 0){ return advancedMatching; }} return false }, loadPixel: function (){ if(initialized||!this.isEnabled()||!Utils.consentGiven('facebook')){ return; } !function (f, b, e, v, n, t, s){ if(f.fbq) return; n=f.fbq=function (){ n.callMethod ? n.callMethod.apply(n, arguments):n.queue.push(arguments) }; if(!f._fbq) f._fbq=n; n.push=n; n.loaded = !0; n.version='2.0'; n.agent='dvpixelyoursite'; n.queue=[]; t=b.createElement(e); t.async = !0; t.src=v; s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s) }(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js'); let expires=parseInt(options.cookie_duration); if(!Cookies.get('_fbp')){ Cookies.set('_fbp',genereateFbp(), { expires: expires }); } if(getUrlParameter('fbclid')){ Cookies.set('_fbc',genereateFbc(), { expires: expires }); } options.facebook.pixelIds.forEach(function (pixelId){ if(options.facebook.removeMetadata){ fbq('set', 'autoConfig', false, pixelId); } let advancedMatching=Facebook.advancedMatching(); if(options.gdpr.consent_magic_integration_enabled&&typeof CS_Data!=="undefined"){ if(!advancedMatching){ fbq('init', pixelId); }else{ var test_prefix=CS_Data.test_prefix; var cs_advanced_matching=Cookies.get('cs_enabled_advanced_matching'+test_prefix); if(jQuery('#cs_enabled_advanced_matching'+test_prefix).length > 0){ if(cs_advanced_matching=='yes'){ fbq('init', pixelId, advancedMatching); }else{ fbq('init', pixelId); }}else{ fbq('init', pixelId, advancedMatching); }} }else{ if(!advancedMatching){ fbq('init', pixelId); }else{ fbq('init', pixelId, advancedMatching); }} }); initialized=true; Utils.fireStaticEvents('facebook'); }, fireEvent: function (name, data){ if(!initialized||!this.isEnabled()){ return false; } data.delay=data.delay||0; data.params=data.params||{}; if(data.delay===0){ fireEvent(name, data); }else{ setTimeout(function (name, params){ fireEvent(name, params); }, data.delay * 1000, name, data); } return true; }, onCommentEvent: function (event){ this.fireEvent(event.name, event); }, onDownloadEvent: function (event){ this.fireEvent(event.name, event); }, onFormEvent: function (event){ this.fireEvent(event.name, event); }, onWooAddToCartOnButtonEvent: function (product_id){ if(!options.dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag())) return; var event=options.dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]; if(window.pysWooProductData.hasOwnProperty(product_id)){ if(window.pysWooProductData[product_id].hasOwnProperty('facebook')){ event=Utils.copyProperties(event, {}) Utils.copyProperties(window.pysWooProductData[product_id]['facebook'].params, event.params) this.fireEvent(event.name, event); }} }, onWooAddToCartOnSingleEvent: function (product_id, qty, product_type, $form){ window.pysWooProductData=window.pysWooProductData||[]; if(!options.dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag())) return; var event=Utils.clone(options.dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]); if(product_type===Utils.PRODUCT_VARIABLE&&!options.facebook.wooVariableAsSimple){ product_id=parseInt($form.find('input[name="variation_id"]').val()); } if(window.pysWooProductData.hasOwnProperty(product_id)){ if(window.pysWooProductData[product_id].hasOwnProperty('facebook')){ Utils.copyProperties(window.pysWooProductData[product_id]['facebook'].params, event.params); var groupValue=0; if(product_type===Utils.PRODUCT_GROUPED){ $form.find(".woocommerce-grouped-product-list .qty").each(function(index){ var childId=$(this).attr('name').replaceAll("quantity[","").replaceAll("]",""); var quantity=parseInt($(this).val()); if(isNaN(quantity)){ quantity=0; } var childItem=window.pysWooProductData[product_id]['facebook'].grouped[childId]; if(quantity==0){ event.params.content_ids.forEach(function(el,index,array){ if(el==childItem.content_id){ array.splice(index, 1); }}); } if(event.params.hasOwnProperty('contents')){ event.params.contents.forEach(function(el,index,array){ if(el.id==childItem.content_id){ if(quantity > 0){ el.quantity=quantity; }else{ array.splice(index, 1); }} }); } groupValue +=childItem.price * quantity; }); if(groupValue==0) return; } if(options.woo.addToCartOnButtonValueEnabled&&options.woo.addToCartOnButtonValueOption!=='global'){ if(product_type===Utils.PRODUCT_GROUPED){ event.params.value=groupValue; }else if(product_type===Utils.PRODUCT_BUNDLE){ var data=$(".bundle_form .bundle_data").data("bundle_form_data"); var items_sum=getBundlePriceOnSingleProduct(data); event.params.value=(parseInt(data.base_price) + items_sum)* qty; }else{ event.params.value=event.params.value * qty; }} if(event.params.hasOwnProperty('contents')&&product_type!==Utils.PRODUCT_GROUPED){ event.params.contents[0].quantity=qty; } this.fireEvent(event.name, event); }} }, onWooRemoveFromCartEvent: function (event){ this.fireEvent(event.name, event); }, onEddAddToCartOnButtonEvent: function (download_id, price_index, qty){ if(!options.dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag())) return; var event=Utils.clone(options.dynamicEvents.edd_add_to_cart_on_button_click[this.tag()]); if(window.pysEddProductData.hasOwnProperty(download_id)){ var index; if(price_index){ index=download_id + '_' + price_index; }else{ index=download_id; } if(window.pysEddProductData[download_id].hasOwnProperty(index)){ if(window.pysEddProductData[download_id][index].hasOwnProperty('facebook')){ Utils.copyProperties(window.pysEddProductData[download_id][index]['facebook']["params"], event.params) if(options.edd.addToCartOnButtonValueEnabled&&options.edd.addToCartOnButtonValueOption!=='global'){ event.params.value=event.params.value * qty; } var contents=event.params.contents; contents[0].quantity=qty; event.params.contents=contents; this.fireEvent(event.name,event); }} }}, onEddRemoveFromCartEvent: function (event){ this.fireEvent(event.name, event); }, onPageScroll: function (event){ this.fireEvent(event.name, event); }, onTime: function (event){ this.fireEvent(event.name, event); }, initEventIdCookies: function (key){ var ids={}; ids[key]=pys_generate_token(36) Cookies.set('pys_fb_event_id', JSON.stringify(ids)); }, updateEventId:function(key){ var cooData=Cookies.get("pys_fb_event_id") if(cooData===undefined){ this.initEventIdCookies(key); }else{ var data=JSON.parse(cooData); data[key]=pys_generate_token(36); Cookies.set('pys_fb_event_id', JSON.stringify(data)); }}, getEventId:function (key){ var data=Cookies.get("pys_fb_event_id"); if(data===undefined){ this.initEventIdCookies(key); data=Cookies.get("pys_fb_event_id"); } return JSON.parse(data)[key]; }, };}(options); var Analytics=function (options){ var initialized=false; function fireEvent(name, data){ if(typeof window.pys_event_data_filter==="function"&&window.pys_disable_event_filter(name,'ga')){ return; } var eventParams=Utils.copyProperties(data, {}); var _fireEvent=function (tracking_id,name,params){ params['send_to']=tracking_id; if(options.debug){ console.log('[Google Analytics #' + tracking_id + '] ' + name, params); } gtag('event', name, params); }; options.ga.trackingIds.forEach(function (tracking_id){ var copyParams=Utils.copyProperties(eventParams, {}); var params=mapParamsTov4(tracking_id,name,copyParams) _fireEvent(tracking_id,name,params); }); } function mapParamsTov4(tag,name,param){ delete param.landing_page; if(isv4(tag)){ delete param.traffic_source; delete param.event_category; delete param.event_label; delete param.ecomm_prodid; delete param.ecomm_pagetype; delete param.ecomm_totalvalue; if(name==='search'){ param['search']=param.search_term; delete param.search_term; delete param.dynx_itemid; delete param.dynx_pagetype; delete param.dynx_totalvalue; }} return param; } function isv4(tag){ return tag.indexOf('G')===0; } return { tag: function(){ return "ga"; }, isEnabled: function (){ return options.hasOwnProperty('ga'); }, disable: function (){ initialized=false; }, loadPixel: function (){ if(initialized||!this.isEnabled()||!Utils.consentGiven('analytics')){ return; } Utils.loadGoogleTag(options.ga.trackingIds[0]); var config={}; if(options.ga.crossDomainEnabled){ config.linker={ accept_incoming: options.ga.crossDomainAcceptIncoming, domains: options.ga.crossDomainDomains };} options.ga.trackingIds.forEach(function (trackingId,index){ var obj=options.ga.isDebugEnabled; var searchValue="index_"+index; var config_for_tag=Object.assign({}, options.config); config_for_tag.debug_mode=false; config_for_tag.send_page_view = !options.ga.custom_page_view_event; for (var key in obj){ if(obj.hasOwnProperty(key)&&obj[key]===searchValue){ config_for_tag.debug_mode=true; break; }} if(!config_for_tag.debug_mode){ delete config_for_tag.debug_mode; } if(isv4(trackingId)){ if(options.ga.disableAdvertisingFeatures){ config_for_tag.allow_google_signals=false } if(options.ga.disableAdvertisingPersonalization){ config_for_tag.allow_ad_personalization_signals=false }} if(options.ga.hasOwnProperty('additionalConfig')){ if(options.ga.additionalConfig.hasOwnProperty(trackingId)&&options.ga.additionalConfig[trackingId]){ config_for_tag.first_party_collection=options.ga.additionalConfig[trackingId].first_party_collection; }} if(options.ga.hasOwnProperty('serverContainerUrls')){ if(options.ga.serverContainerUrls.hasOwnProperty(trackingId)&&options.ga.serverContainerUrls[trackingId].enable_server_container!=false){ if(options.ga.serverContainerUrls[trackingId].server_container_url!=''){ config_for_tag.server_container_url=options.ga.serverContainerUrls[trackingId].server_container_url; } if(options.ga.serverContainerUrls[trackingId].transport_url!=''){ config_for_tag.transport_url=options.ga.serverContainerUrls[trackingId].transport_url; }} } if(options.gdpr.cookiebot_integration_enabled&&typeof Cookiebot!=='undefined'){ var cookiebot_consent_category=options.gdpr['cookiebot_analytics_consent_category']; if(options.gdpr['analytics_prior_consent_enabled']){ if(Cookiebot.consented===true&&Cookiebot.consent[cookiebot_consent_category]){ gtag('config', trackingId, config_for_tag); }}else{ if(Cookiebot.consent[cookiebot_consent_category]){ gtag('config', trackingId, config_for_tag); }} }else{ gtag('config', trackingId, config_for_tag); }}); initialized=true; Utils.fireStaticEvents('ga'); }, fireEvent: function (name, data){ if(!initialized||!this.isEnabled()){ return false; } data.delay=data.delay||0; data.params=data.params||{}; data.params.eventID=Utils.generateUniqueId(data); if(data.delay===0){ fireEvent(name, data.params); }else{ setTimeout(function (name, params){ fireEvent(name, params); }, data.delay * 1000, name, data.params); } return true; }, onCommentEvent: function (event){ this.fireEvent(event.name, event); }, onDownloadEvent: function (event){ this.fireEvent(event.name, event); }, onFormEvent: function (event){ this.fireEvent(event.name, event); }, onWooAddToCartOnButtonEvent: function (product_id){ if(!options.dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag())) return; var event=Utils.clone(options.dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]); if(window.pysWooProductData.hasOwnProperty(product_id)){ if(window.pysWooProductData[product_id].hasOwnProperty('ga')){ Utils.copyProperties(window.pysWooProductData[product_id]['ga'].params, event.params) this.fireEvent(event.name, event); }} }, onWooAddToCartOnSingleEvent: function (product_id, qty, product_type, $form){ window.pysWooProductData=window.pysWooProductData||[]; if(!options.dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag())) return; var event=Utils.clone(options.dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]); if(product_type===Utils.PRODUCT_VARIABLE&&!options.ga.wooVariableAsSimple){ product_id=parseInt($form.find('input[name="variation_id"]').val()); } if(window.pysWooProductData.hasOwnProperty(product_id)){ if(window.pysWooProductData[product_id].hasOwnProperty('ga')){ Utils.copyProperties(window.pysWooProductData[product_id]['ga'].params, event.params); if(product_type===Utils.PRODUCT_GROUPED){ var groupValue=0; $form.find(".woocommerce-grouped-product-list .qty").each(function(index){ var childId=$(this).attr('name').replaceAll("quantity[","").replaceAll("]",""); var quantity=parseInt($(this).val()); if(isNaN(quantity)){ quantity=0; } var childItem=window.pysWooProductData[product_id]['ga'].grouped[childId]; event.params.items.forEach(function(el,index,array){ if(el.id==childItem.content_id){ if(quantity > 0){ el.quantity=quantity; }else{ array.splice(index, 1); }} }); groupValue +=childItem.price * quantity; }); if(options.woo.addToCartOnButtonValueEnabled && options.woo.addToCartOnButtonValueOption!=='global' && event.params.hasOwnProperty('ecomm_totalvalue')){ event.params.ecomm_totalvalue=groupValue; } if(groupValue==0) return; }else{ event.params.items[0].quantity=qty; } if(options.woo.addToCartOnButtonValueEnabled && options.woo.addToCartOnButtonValueOption!=='global' && product_type!==Utils.PRODUCT_GROUPED){ if(event.params.hasOwnProperty('ecomm_totalvalue')){ event.params.ecomm_totalvalue=event.params.items[0].price * qty; }} this.fireEvent(event.name, event); }} }, onWooRemoveFromCartEvent: function (event){ this.fireEvent(event.name, event); }, onEddAddToCartOnButtonEvent: function (download_id, price_index, qty){ if(!options.dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag())) return; var event=Utils.clone(options.dynamicEvents.edd_add_to_cart_on_button_click[this.tag()]); if(window.pysEddProductData.hasOwnProperty(download_id)){ var index; if(price_index){ index=download_id + '_' + price_index; }else{ index=download_id; } if(window.pysEddProductData[download_id].hasOwnProperty(index)){ if(window.pysEddProductData[download_id][index].hasOwnProperty('ga')){ Utils.copyProperties(window.pysEddProductData[download_id][index]['ga'].params, event.params); event.params.items[0].quantity=qty; this.fireEvent(event.name,event); }} }}, onEddRemoveFromCartEvent: function (event){ this.fireEvent(event.name, event); }, onPageScroll: function (event){ this.fireEvent(event.name, event); }, onTime: function (event){ this.fireEvent(event.name, event); }, };}(options); window.pys=window.pys||{}; window.pys.Facebook=Facebook; window.pys.Analytics=Analytics; window.pys.Utils=Utils; $(document).ready(function (){ if($("#pys_late_event").length > 0){ var events=JSON.parse($("#pys_late_event").attr("dir")); for(var key in events){ var event={}; event[events[key].e_id]=[events[key]]; if(options.staticEvents.hasOwnProperty(key)){ Object.assign(options.staticEvents[key], event); }else{ options.staticEvents[key]=event; }} } var Pinterest=Utils.setupPinterestObject(); var Bing=Utils.setupBingObject(); if(options.hasOwnProperty('cookie')){ if(options.cookie.externalID_disabled_by_api||options.cookie.disabled_all_cookie){ Cookies.remove('pbid') } if(options.cookie.disabled_advanced_form_data_cookie||options.cookie.disabled_all_cookie){ Cookies.remove('pys_advanced_form_data') } if(options.cookie.disabled_landing_page_cookie||options.cookie.disabled_all_cookie){ Cookies.remove('pys_landing_page') Cookies.remove('last_pys_landing_page') } if(options.cookie.disabled_trafficsource_cookie||options.cookie.disabled_all_cookie){ Cookies.remove('pysTrafficSource') Cookies.remove('last_pysTrafficSource') } if(options.cookie.disabled_first_visit_cookie||options.cookie.disabled_all_cookie){ Cookies.remove('pys_first_visit') } if(options.cookie.disabled_utmTerms_cookie||options.cookie.disabled_all_cookie){ $.each(Utils.utmTerms, function (index, name){ Cookies.remove('pys_' + name) }); $.each(Utils.utmTerms, function (index, name){ Cookies.remove('last_pys_' + name) }); } if(options.cookie.disabled_utmId_cookie||options.cookie.disabled_all_cookie){ $.each(Utils.utmId,function(index,name){ Cookies.remove('pys_' + name) }) $.each(Utils.utmId,function(index,name){ Cookies.remove('last_pys_' + name) }); }} if(options.gdpr.cookie_law_info_integration_enabled){ var cli_cookie=Cookies.get('cookieyes-consent') ?? Cookies.get('viewed_cookie_policy'); if(typeof cli_cookie!=='undefined'){ if(cli_cookie===Cookies.get('cookieyes-consent')&&getCookieYes('analytics')=='yes'){ Utils.manageCookies(); }else if(cli_cookie===Cookies.get('viewed_cookie_policy')&&cli_cookie=='yes'){ Utils.manageCookies(); }} } if(options.gdpr.consent_magic_integration_enabled&&typeof CS_Data!=="undefined"){ if(CS_Data.cs_script_cat.pys==CS_Data.cs_necessary_cat_id||CS_Data.cs_script_cat.pys==0){ Utils.manageCookies(); }else if(Cookies.get('cs_enabled_cookie_term' + CS_Data.test_prefix + '_' + CS_Data.cs_script_cat.pys)=='yes'){ Utils.manageCookies(); }}else{ Utils.manageCookies(); } Utils.setupGdprCallbacks(); if(options.dynamicEvents.hasOwnProperty("automatic_event_scroll") ){ var singlePageScroll=function (){ var docHeight=$(document).height() - $(window).height(); var isFired=false; if(options.dynamicEvents.hasOwnProperty("automatic_event_scroll")){ var pixels=Object.keys(options.dynamicEvents.automatic_event_scroll); for(var i=0;i<pixels.length;i++){ var event=Utils.clone(options.dynamicEvents.automatic_event_scroll[pixels[i]]); var scroll=Math.round(docHeight * event.scroll_percent / 100) if(scroll < $(window).scrollTop()){ Utils.copyProperties(Utils.getRequestParams(), event.params); getPixelBySlag(pixels[i]).onPageScroll(event); isFired=true }} } if(isFired){ $(document).off("scroll",singlePageScroll); }} $(document).on("scroll",singlePageScroll); } if(options.dynamicEvents.hasOwnProperty("automatic_event_time_on_page")){ var pixels=Object.keys(options.dynamicEvents.automatic_event_time_on_page); var time=options.dynamicEvents.automatic_event_time_on_page[pixels[0]].time_on_page; setTimeout(function(){ for(var i=0;i<pixels.length;i++){ var event=Utils.clone(options.dynamicEvents.automatic_event_time_on_page[pixels[i]]); Utils.copyProperties(Utils.getRequestParams(), event.params); getPixelBySlag(pixels[i]).onTime(event); }},time*1000); } if(options.dynamicEvents.hasOwnProperty("automatic_event_download")){ $(document).onFirst('click', 'a, button, input[type="button"], input[type="submit"]', function (e){ var $elem=$(this); if(options.dynamicEvents.hasOwnProperty("automatic_event_download") ){ var isFired=false; if($elem.is('a')){ var href=$elem.attr('href'); if(typeof href!=="string"){ return; } href=href.trim(); var extension=Utils.getLinkExtension(href); var track_download=false; if(extension.length > 0){ if(options.dynamicEvents.hasOwnProperty("automatic_event_download")){ var pixels=Object.keys(options.dynamicEvents.automatic_event_download); for (var i=0; i < pixels.length; i++){ var event=Utils.clone(options.dynamicEvents.automatic_event_download[pixels[i]]); var extensions=event.extensions; if(extensions.includes(extension)){ if(pixels[i]=="tiktok"){ getPixelBySlag(pixels[i]).fireEvent(tikEvent.name, event); }else{ if(options.enable_remove_download_url_param){ href=href.split('?')[0]; } event.params.download_url=href; event.params.download_type=extension; event.params.download_name=Utils.getLinkFilename(href); getPixelBySlag(pixels[i]).onDownloadEvent(event); } isFired=true; }} }} } if(isFired){ return; }} }); } $.each(options.triggerEventTypes, function (triggerType, events){ $.each(events, function (eventId, triggers){ switch (triggerType){ case 'url_click': break; case 'css_click': Utils.setupCSSClickEvents(eventId, triggers); break; case 'css_mouseover': Utils.setupMouseOverClickEvents(eventId, triggers); break; case 'scroll_pos': Utils.setupScrollPosEvents(eventId, triggers); break; case 'comment': Utils.setupCommentEvents(eventId, triggers); break; }}); }); if(options.woo.enabled){ if(options.dynamicEvents.hasOwnProperty("woo_add_to_cart_on_button_click") && options.woo.hasOwnProperty("addToCartCatchMethod") && options.woo.addToCartCatchMethod==="add_cart_js" ){ $('.add_to_cart_button:not(.product_type_variable,.product_type_bundle,.single_add_to_cart_button)').on("click",function (e){ var product_id=$(this).data('product_id'); if(typeof product_id!=='undefined'){ Facebook.onWooAddToCartOnButtonEvent(product_id); Analytics.onWooAddToCartOnButtonEvent(product_id); Pinterest.onWooAddToCartOnButtonEvent(product_id); Bing.onWooAddToCartOnButtonEvent(product_id); }}); $('body').onFirst('click','button.single_add_to_cart_button,.single_add_to_cart_button',function (e){ var $button=$(this); if($button.hasClass('disabled')){ return; } var $form=$button.closest('form'); var product_type=Utils.PRODUCT_SIMPLE; if($form.length===0){ return ; }else if($form.hasClass('variations_form')){ product_type=Utils.PRODUCT_VARIABLE; }else if($form.hasClass('bundle_form')){ product_type=Utils.PRODUCT_BUNDLE; }else if($form.hasClass('grouped_form')){ product_type=Utils.PRODUCT_GROUPED; } var product_id; var qty; if(product_type===Utils.PRODUCT_GROUPED){ qty=1; product_id=parseInt($form.find('*[name="add-to-cart"]').val()); }else if(product_type===Utils.PRODUCT_VARIABLE){ product_id=parseInt($form.find('*[name="add-to-cart"]').val()); var qtyTag=$form.find('input[name="quantity"]'); if(qtyTag.length <=0){ qtyTag=$form.find('select[name="quantity"]'); } qty=parseInt(qtyTag.val()); }else{ product_id=parseInt($form.find('*[name="add-to-cart"]').val()); var qtyTag=$form.find('input[name="quantity"]'); if(qtyTag.length <=0){ qtyTag=$form.find('select[name="quantity"]'); } qty=parseInt(qtyTag.val()); } Facebook.onWooAddToCartOnSingleEvent(product_id, qty, product_type, $form); Analytics.onWooAddToCartOnSingleEvent(product_id, qty, product_type, $form); Pinterest.onWooAddToCartOnSingleEvent(product_id, qty, product_type, false, $form); Bing.onWooAddToCartOnSingleEvent(product_id, qty, product_type, false, $form); }); } if(options.dynamicEvents.hasOwnProperty("woo_remove_from_cart")){ $('body').on('click', options.woo.removeFromCartSelector, function (e){ var $a=$(e.currentTarget), href=$a.attr('href'); var regex=new RegExp("[\\?&]remove_item=([^&#]*)"), results=regex.exec(href); if(results!==null){ var item_hash=results[1]; if(options.dynamicEvents["woo_remove_from_cart"].hasOwnProperty(item_hash)){ var events=options.dynamicEvents["woo_remove_from_cart"][item_hash]; Utils.fireEventForAllPixel("onWooRemoveFromCartEvent",events) }} }); }} if(options.edd.enabled){ if(options.dynamicEvents.hasOwnProperty("edd_add_to_cart_on_button_click")){ $('form.edd_download_purchase_form .edd-add-to-cart').on("click",function (e){ var $button=$(this); var $form=$button.closest('form'); var variable_price=$button.data('variablePrice'); var price_mode=$button.data('priceMode'); var ids=[]; var quantities=[]; var qty; var id; if(variable_price==='yes'&&price_mode==='multi'){ id=$form.find('input[name="download_id"]').val(); $.each($form.find('input[name="edd_options[price_id][]"]:checked'), function (i, el){ ids.push(id + '_' + $(el).val()); }); $.each(ids, function (i, variant_id){ var variant_index=variant_id.split('_', 2); qty=$form.find('input[name="edd_download_quantity_' + variant_index[1] + '"]').val(); if(typeof qty!=='undefined'){ quantities.push(qty); }else{ quantities.push(1); }}); }else if(variable_price==='yes'&&price_mode==='single'){ id=$form.find('input[name="download_id"]').val(); ids.push(id + '_' + $form.find('input[name="edd_options[price_id][]"]:checked').val()); qty=$form.find('input[name="edd_download_quantity"]').val(); if(typeof qty!=='undefined'){ quantities.push(qty); }else{ quantities.push(1); }}else{ ids.push($button.data('downloadId')); qty=$form.find('input[name="edd_download_quantity"]').val(); if(typeof qty!=='undefined'){ quantities.push(qty); }else{ quantities.push(1); }} $.each(ids, function (i, download_id){ var q=parseInt(quantities[i]); var variant_index=download_id.toString().split('_', 2); var price_index; if(variant_index.length===2){ download_id=variant_index[0]; price_index=variant_index[1]; } Facebook.onEddAddToCartOnButtonEvent(download_id, price_index, q); Analytics.onEddAddToCartOnButtonEvent(download_id, price_index, q); Pinterest.onEddAddToCartOnButtonEvent(download_id, price_index, q); Bing.onEddAddToCartOnButtonEvent(download_id, price_index, q); }); }); } if(options.dynamicEvents.hasOwnProperty("edd_remove_from_cart")){ $('form#edd_checkout_cart_form .edd_cart_remove_item_btn').on("click",function (e){ var href=$(this).attr('href'); if(href){ var key=href.substring(href.indexOf('=') + 1).charAt(0); if(options.dynamicEvents.edd_remove_from_cart.hasOwnProperty(key)){ var events=options.dynamicEvents.edd_remove_from_cart[key]; Utils.fireEventForAllPixel("onEddRemoveFromCartEvent",events) }} }); }} if(options.dynamicEvents.hasOwnProperty("automatic_event_comment") ){ $('form.comment-form').on("submit",function (){ if(options.dynamicEvents.hasOwnProperty("automatic_event_comment")){ var pixels=Object.keys(options.dynamicEvents.automatic_event_comment); for (var i=0; i < pixels.length; i++){ var event=Utils.clone(options.dynamicEvents.automatic_event_comment[pixels[i]]); Utils.copyProperties(Utils.getRequestParams(), event.params); getPixelBySlag(pixels[i]).onCommentEvent(event); }} }); } if(options.dynamicEvents.hasOwnProperty("automatic_event_form")){ $(document).onFirst('submit', 'form', function (e){ var $form=$(this); if($form.hasClass('comment-form')||$form.hasClass('search-form')||$form.attr('id')==='adminbarsearch'){ return; } if($form.hasClass('woocommerce-product-search')||$form.hasClass('cart')||$form.hasClass('woocommerce-cart-form') || $form.hasClass('woocommerce-shipping-calculator')||$form.hasClass('checkout')||$form.hasClass('checkout_coupon')){ return; } if($form.hasClass('edd_form')||$form.hasClass('edd_download_purchase_form')){ return; } if($form.hasClass('wpcf7-form')){ return; } if($form.hasClass('forminator-custom-form')||$form.hasClass('forminator_ajax')){ return; } if($form.hasClass('wpforms-form')||$form.hasClass('wpforms-ajax-form')){ return; } if($form.parent().hasClass('nf-form-layout')){ return; } if($form.hasClass('frm-fluent-form')){ return; } if(!options.enable_success_send_form){ var params={ form_id: $form.attr('id'), form_class: $form.attr('class'), text: $form.find('[type="submit"]').is('input') ? $form.find('[type="submit"]').val():$form.find('[type="submit"]').text() }; if(options.dynamicEvents.hasOwnProperty("automatic_event_form")){ var pixels=Object.keys(options.dynamicEvents.automatic_event_form); for (var i=0; i < pixels.length; i++){ var event=Utils.clone(options.dynamicEvents.automatic_event_form[pixels[i]]); if(pixels[i]==="tiktok"){ getPixelBySlag(pixels[i]).fireEvent(event.name, event); }else{ Utils.copyProperties(params, event.params,) Utils.copyProperties(Utils.getRequestParams(), event.params); getPixelBySlag(pixels[i]).onFormEvent(event); }} }} }); document.addEventListener('wpcf7mailsent', function(event){ var form_id=event.detail.contactFormId; sendFormAction($(event.target), form_id); }, false); $(document).on('forminator:form:submit:success', function(event){ var form_id=$(event.target).find('input[name="form_id"]').val(); sendFormAction($(event.target), form_id); }); $('form.wpforms-form').on('wpformsAjaxSubmitSuccess', (event)=> { var form_id=$(event.target).attr('data-formid'); sendFormAction($(event.target), form_id); }) $(document).on('frmFormComplete', function(event, form, response){ const form_id=$(form).find('input[name="form_id"]').val(); sendFormAction($(event.target), form_id); }); $(document).onFirst('nfFormSubmitResponse', function (event, data){ const form_id=data.response.data.form_id; sendFormAction($(event.target), form_id); }); var fluentForms=$('form.frm-fluent-form'); fluentForms.each(function(){ var $form=$(this); $form.on('fluentform_submission_success', function(event){ var $formItem=$(this); var form_id=$formItem.attr('data-form_id'); sendFormAction($(event.target), form_id); }); }); } Utils.loadPixels(); if(Utils.isCheckoutPage()){ Utils.addCheckoutFields(); }}); var sendFormAction=function (form_target, formId){ var params={ form_id: formId, text: form_target.find('[type="submit"]').is('input') ? form_target.find('[type="submit"]').val() : form_target.find('.forminator-button-submit').text()!='' ? form_target.find('.forminator-button-submit').text() : form_target.find('[type="submit"]').text() }; if(options.dynamicEvents.hasOwnProperty("automatic_event_form")){ var pixels=Object.keys(options.dynamicEvents.automatic_event_form); for (var i=0; i < pixels.length; i++){ var event=options.dynamicEvents.automatic_event_form[pixels[i]]; if(pixels[i]==="tiktok"){ getPixelBySlag(pixels[i]).fireEvent(event.name, event); }else{ Utils.copyProperties(params, event.params) Utils.copyProperties(Utils.getRequestParams(), event.params); getPixelBySlag(pixels[i]).onFormEvent(event); }} }} }(jQuery, pysOptions); function pys_generate_token(){ return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c=> (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ); } function getBundlePriceOnSingleProduct(data){ var items_sum=0; jQuery(".bundle_form .bundled_product").each(function(index){ var id=jQuery(this).find(".cart").data("bundled_item_id"); var item_price=data.prices[id]; var item_quantity=jQuery(this).find(".bundled_qty").val(); if(!jQuery(this).hasClass("bundled_item_optional") || jQuery(this).find(".bundled_product_optional_checkbox input").prop('checked')){ items_sum +=item_price*item_quantity; }}); return items_sum; } function getPixelBySlag(slug){ switch (slug){ case "facebook": return window.pys.Facebook; case "ga": return window.pys.Analytics; case "bing": return window.pys.Bing; case "pinterest": return window.pys.Pinterest; }} var getUrlParameter=function getUrlParameter(sParam){ var sPageURL=window.location.search.substring(1), sURLVariables=sPageURL.split('&'), sParameterName, i; for (i=0; i < sURLVariables.length; i++){ sParameterName=sURLVariables[i].split('='); if(sParameterName[0]===sParam){ return sParameterName[1]===undefined ? true:decodeURIComponent(sParameterName[1]); }} return false; }; function getCookieYes(key){ const cookies=document.cookie .split(";") .reduce((ac, cv, i)=> Object.assign(ac, { [cv.split("=")[0].trim()]: cv.split("=")[1] }), {} )["cookieyes-consent"]; const { [key]: value }=cookies .split(",") .reduce((obj, pair)=> ( (pair=pair.split(":")), (obj[pair[0]]=pair[1]), obj ), {} ); return value; }; jQuery(document).ready(function($){ var isCartPage=xoo_wsc_params.isCart=='1', isCheckoutPage=xoo_wsc_params.isCheckout=='1'; var get_wcurl=function(endpoint){ return xoo_wsc_params.wc_ajax_url.toString().replace('%%endpoint%%', endpoint ); }; class Notice{ static markupTimeout=null; constructor($modal){ this.$modal=$modal; this.timeout=null; } add(notice, type='success', clearPrevious=true){ var $noticeCont=this.$modal.find('.xoo-wsc-notice-container'); if(clearPrevious){ $noticeCont.html(''); } var noticeHTML=type==='success' ? xoo_wsc_params.html.successNotice.toString().replace('%s%', notice):xoo_wsc_params.html.errorNotice.toString().replace('%s%', notice); $noticeCont.html(noticeHTML); } showNotification(){ Notice.showMarkupNotice(); var $noticeCont=this.$modal.find('.xoo-wsc-notice-container'); if(!$noticeCont.length||$noticeCont.children().length===0) return; $noticeCont.slideDown(); clearTimeout(this.timeout); this.timeout=setTimeout(function(){ $noticeCont.slideUp('slow',function(){ }); },xoo_wsc_params.notificationTime) } hideNotification(){ this.$modal.find('.xoo-wsc-notice-container').hide(); } static hideMarkupNotice(){ Notice.$noticeContainer().removeClass('xoo-wsc-active'); } static $noticeContainer(){ return $('.xoo-wsc-markup-notices') } static showMarkupNotice(){ if(cart.isOpen()) return; var $markupNotice=Notice.$noticeContainer(); var $notices=$markupNotice.find('.xoo-wsc-notice-container .xoo-wsc-notices'); if(!$notices.length||$notices.children().length===0) return; setTimeout(function(){$markupNotice.addClass('xoo-wsc-active')},10); clearTimeout(Notice.markupTimeout); Notice.markupTimeout=setTimeout(function(){ $markupNotice.removeClass('xoo-wsc-active'); },xoo_wsc_params.notificationTime) }} class Container{ constructor($modal, container){ this.$modal=$modal; this.container=container||'cart'; this.notice=new Notice(this.$modal); } isOpen(){ return this.$modal.hasClass('xoo-wsc-'+this.container+'-active'); } eventHandlers(){ $(document.body).on('wc_fragments_refreshed updated_checkout', this.onCartUpdate.bind(this)); } onCartUpdate(){ this.unblock(); this.notice.showNotification(); } setAjaxData(data, noticeSection){ var ajaxData={ container: this.container, noticeSection: noticeSection||this.noticeSection||this.container, isCheckout: isCheckoutPage, isCart: isCartPage } if(typeof data==='object'){ $.extend(ajaxData, data); }else{ var serializedData=data; $.each(ajaxData, function(key, value){ serializedData +=('&'+key+'='+value); }) ajaxData=serializedData; } return ajaxData; } toggle(type){ var $activeEls=this.$modal.add('body').add('html'), activeClass='xoo-wsc-'+ this.container +'-active'; if(type==='show'){ $activeEls.addClass(activeClass); } else if(type==='hide'){ $activeEls.removeClass(activeClass); }else{ $activeEls.toggleClass(activeClass); } $(document.body).trigger('xoo_wsc_' + this.container + '_toggled', [ type ]); this.notice.hideNotification(); } block(){ this.$modal.addClass('xoo-wsc-loading'); } unblock(){ this.$modal.removeClass('xoo-wsc-loading'); } refreshMyFragments(){ if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){ $(document.body).trigger('wc_fragment_refresh'); return; } this.block(); $.ajax({ url: get_wcurl('xoo_wsc_refresh_fragments'), type: 'POST', context: this, data: {}, success: function(response){ this.updateFragments(response); }, complete: function(){ this.unblock(); }}) } updateCartCheckoutPage(){ if(isCheckoutPage){ if($('form.checkout').length===0){ location.reload(); return; } $(document.body).trigger("update_checkout"); } if(isCartPage){ $(document.body).trigger("wc_update_cart"); }} updateFragments(response){ console.log('updated'); if(response.fragments){ $(document.body).trigger('xoo_wsc_before_loading_fragments', [ response ]); this.block(); $.each(response.fragments, function(key, value){ $(key).replaceWith(value); }); if(typeof wc_cart_fragments_params!=='undefined'&&('sessionStorage' in window&&window.sessionStorage!==null)){ sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(response.fragments)); localStorage.setItem(wc_cart_fragments_params.cart_hash_key, response.cart_hash); sessionStorage.setItem(wc_cart_fragments_params.cart_hash_key, response.cart_hash); if(response.cart_hash){ sessionStorage.setItem('wc_cart_created',(new Date()).getTime()); }} $(document.body).trigger('wc_fragments_refreshed'); this.unblock(); } if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){ this.block(); $(document.body).trigger('wc_fragment_refresh'); return; }} } class Cart extends Container{ constructor($modal){ super($modal, 'cart'); this.refreshFragmentsOnPageLoad(); this.eventHandlers(); } refreshFragmentsOnPageLoad(){ setTimeout(function(){ this.refreshMyFragments(); }.bind(this), xoo_wsc_params.fetchDelay) } eventHandlers(){ super.eventHandlers(); this.$modal.on('click', '.xoo-wsc-smr-del', this.deleteIconClick.bind(this)); this.$modal.on('click', '.xoo-wsch-close, .xoo-wsc-opac, .xoo-wsc-cart-close', this.closeCartOnClick.bind(this)); this.$modal.on('click', '.xoo-wsc-basket', this.toggleCart.bind(this)); $(document.body).on('xoo_wsc_cart_updated', this.updateCartCheckoutPage.bind(this)); $(document.body).on('click', 'a.added_to_cart, .xoo-wsc-cart-trigger', this.openCart.bind(this)); $(document.body).on('added_to_cart', this.addedToCart.bind(this)); $(document.body).on('wc-blocks_added_to_cart', this.blockAddedToCart.bind(this)); if(xoo_wsc_params.autoOpenCart==='yes'&&xoo_wsc_params.addedToCart==='yes'){ this.openCart(); } if(xoo_wsc_params.ajaxAddToCart==='yes'){ $(document.body).on('submit', 'form.cart', this.addToCartFormSubmit.bind(this)); } if(typeof wc_cart_fragments_params==='undefined'){ $(window).on('pageshow' , this.onPageShow); } if(xoo_wsc_params.triggerClass){ $(document.body).on('click', '.'+xoo_wsc_params.triggerClass, this.openCart.bind(this)); } if(isCheckoutPage||isCartPage){ $(document.body).on('updated_shipping_method', this.refreshMyFragments.bind(this)); }} toggleCart(e){ if(this.isOpen()){ this.closeCartOnClick(e); }else{ this.openCart(e); }} openCart(e){ if(e){ e.preventDefault(); e.stopImmediatePropagation(); } this.toggle('show'); Notice.hideMarkupNotice(); } addToCartFormSubmit(e){ var $form=$(e.currentTarget); if($form.closest('.product').hasClass('product-type-external')||$form.siblings('.xoo-wsc-disable-atc').length) return; var $button=$(e.originalEvent.submitter), formData=new FormData($form.get(0)), productData=$form.serializeArray(), hasProductId=false; if(!$button.length){ $button=$form.find('button[type="submit"]'); } $.each(productData, function(key, form_item){ if(form_item.name==='productID'||form_item.name==='add-to-cart'){ if(form_item.value){ hasProductId=true; return false; }} }) if(!hasProductId&&$form.attr('action')){ var is_url=$form.attr('action').match(/add-to-cart=([0-9]+)/), productID=is_url ? is_url[1]:false; } if($button.attr('name')&&$button.attr('value')){ formData.append($button.attr('name'), $button.attr('value')); } if(productID){ formData.append('add-to-cart', productID); } formData.append('action', 'xoo_wsc_add_to_cart'); var doAjaxAddToCart=true; $.each(xoo_wsc_params.skipAjaxForData, function(key, value){ if(formData.has(key)&&(!value||formData.get(key)==value)){ doAjaxAddToCart=false; return false; }}) if(doAjaxAddToCart){ e.preventDefault(); this.addToCartAjax($button, formData); }} addToCartAjax($button, formData){ this.block(); $button.addClass('loading'); $(document.body).trigger('adding_to_cart', [ $button, formData ]); $.ajax({ url: get_wcurl('xoo_wsc_add_to_cart'), type: 'POST', context: this, cache: false, contentType: false, processData: false, data: formData, success: function(response){ if(response.fragments){ $(document.body).trigger('added_to_cart', [ response.fragments, response.cart_hash, $button ]); }else if(response.error){ Notice.$noticeContainer().replaceWith(response.notice); Notice.showMarkupNotice(); }else{ window.location.reload(); }}, complete: function(){ this.unblock(); $button .removeClass('loading') .addClass('added'); }}) } addedToCart(e, response, hash, $button){ this.updateFragments({ fragments: response }); this.onCartUpdate(); var _this=this; if(xoo_wsc_params.autoOpenCart==="yes"){ setTimeout(function(){ _this.openCart(); },20) }} blockAddedToCart(){ $(document.body).trigger('wc_fragment_refresh'); this.block(); var _this=this; if(xoo_wsc_params.autoOpenCart==="yes"){ setTimeout(function(){ _this.openCart(); },20) }} closeCartOnClick(e){ e.preventDefault(); this.toggle('hide'); } onPageShow(e){ if(e.originalEvent.persisted){ this.refreshMyFragments(); $(document.body).trigger('wc_fragment_refresh'); }} deleteIconClick(e){ this.updateItemQty($(e.currentTarget).parents('.xoo-wsc-product').data('key'), 0); } updateItemQty(cart_key, qty){ if(!cart_key||qty===undefined) return; this.block(); var formData={ cart_key: cart_key, qty: qty } $.ajax({ url: get_wcurl('xoo_wsc_update_item_quantity'), type: 'POST', context: this, data: this.setAjaxData(formData), success: function(response){ this.updateFragments(response); $(document.body).trigger('xoo_wsc_quantity_updated', [response]); $(document.body).trigger('xoo_wsc_cart_updated', [response]); this.unblock(); }}) } onCartUpdate(){ super.onCartUpdate(); this.showBasket(); } showBasket(){ var $basket=$('.xoo-wsc-basket'), show=xoo_wsc_params.showBasket; if(show==="always_show"){ $basket.show(); } else if(show==="hide_empty"){ if(this.$modal.find('.xoo-wsc-product').length){ $basket.show(); }else{ $basket.hide(); }}else{ $basket.hide(); }} } var cart=new Cart($('.xoo-wsc-modal')); });