Untitled
unknown
plain_text
2 years ago
3.2 kB
9
Indexable
(function () { try { /* main variables */ var debug = 0; /* all Pure helper functions */ function waitForElement(selector, trigger, delayInterval, delayTimeout) { var interval = setInterval(function () { if ( document && document.querySelector(selector) && document.querySelectorAll(selector).length > 0 ) { clearInterval(interval); trigger(); } }, delayInterval); setTimeout(function () { clearInterval(interval); }, delayTimeout); } function live(event, selector, callback, context) { /****Helper Functions****/ // helper for enabling IE 8 event bindings function addEvent(el, type, handler) { if (el.attachEvent) el.attachEvent("on" + type, handler); else el.addEventListener(type, handler); } // matches polyfill this.Element && (function (ElementPrototype) { ElementPrototype.matches = ElementPrototype.matches || ElementPrototype.matchesSelector || ElementPrototype.webkitMatchesSelector || ElementPrototype.msMatchesSelector || function (selector) { var node = this, nodes = ( node.parentNode || node.document ).querySelectorAll(selector), i = -1; while (nodes[++i] && nodes[i] != node); return !!nodes[i]; }; })(Element.prototype); // live binding helper using matchesSelector function live(selector, event, callback, context) { addEvent(context || document, event, function (e) { var found, el = e.target || e.srcElement; while ( el && el.matches && el !== context && !(found = el.matches(selector)) ) el = el.parentElement; if (found) callback.call(el, e); }); } live(selector, event, callback, context); } function init() { window['optimizely'] = window['optimizely'] || []; live('click','.step .step__item button, .step__text a, .s-trial .b-steps-free-trial__btn, .s-trial form.wds-formV2 .mktoFormRow',function(){ window['optimizely'].push({ type: "event", eventName: "Form_engagement", tags: { revenue: 0, // Optional in cents as integer (500 == $5.00) value: 0.00 // Optional as float } }); }); //click goal on complete purchase live('click','#completePurchase',function(){ window['optimizely'].push({ type: "event", eventName: "Complete Purchase", tags: { revenue: 0, // Optional in cents as integer (500 == $5.00) value: 0.00 // Optional as float } }); }); } waitForElement(".step .step__item button, .step__text a, .s-trial .b-steps-free-trial__btn, .s-trial form.wds-formV2, #completePurchase", init, 50, 15000); } catch (e) { if (debug) console.log(e, "error in project js"); } })();
Editor is loading...