Untitled
unknown
plain_text
3 years ago
5.0 kB
10
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
}
});
});
// Pro Buy Now Click
live('click','.s-levels__wrap div[data-level-id="2"] div:first-of-type a',function(){
window['optimizely'].push({
type: "event",
eventName: "Pro Buy Now Click",
tags: {
revenue: 0, // Optional in cents as integer (500 == $5.00)
value: 0.00 // Optional as float
}
});
});
//Compare CTA click
live('click','.s-levels__link-btn .wds-btn._secondary',function(){
window['optimizely'].push({
type: "event",
eventName: "Compare CTA click",
tags: {
revenue: 0, // Optional in cents as integer (500 == $5.00)
value: 0.00 // Optional as float
}
});
});
// Enterprise Buy Now Click
live('click','.s-levels__wrap div[data-level-id="3"] div:first-of-type a',function(){
window['optimizely'].push({
type: "event",
eventName: "Enterprise Buy Now Click",
tags: {
revenue: 0, // Optional in cents as integer (500 == $5.00)
value: 0.00 // Optional as float
}
});
});
//Standard Buy Now Click
live('click','.s-levels__wrap div[data-level-id="1"] div:first-of-type a',function(){
window['optimizely'].push({
type: "event",
eventName: "Standard Buy Now Click",
tags: {
revenue: 0, // Optional in cents as integer (500 == $5.00)
value: 0.00 // Optional as float
}
});
});
//Get a Quote Click
live('click','.l-page__main .get-quote-link',function(){
window['optimizely'].push({
type: "event",
eventName: "Get a Quote Click",
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, body", init, 50, 15000);
} catch (e) {
if (debug) console.log(e, "error in project js");
}
})();Editor is loading...