Files
2017-04-10 20:08:08 -05:00

2 lines
14 KiB
JavaScript

(function(t){function n(t,e){if({}.hasOwnProperty.call(n.cache,t))return n.cache[t];if("function"==typeof e)return void n.load(t,e);var o=n.resolve(t);if(!o)throw new Error("Failed to resolve module "+t);var r={id:t,rqzt:n,filename:t,exports:{},loaded:!1,parent:null,children:[]},i=t.slice(0,t.lastIndexOf("/")+1);return n.cache[t]=r.exports,o.call(r.exports,r,r.exports,i,t),r.loaded=!0,n.cache[t]=r.exports}n.modules={},n.cache={},n.resolve=function(t){return{}.hasOwnProperty.call(n.modules,t)?n.modules[t]:void 0},n.define=function(t,e){n.modules[t]=e},t.require=n,n.define("./analytics",function(t,e,o,r,i){var u,c;c=n("./integration"),t.exports=u=function(){function t(){var t;this.integrations=[],"undefined"!=typeof location&&(this._debug=location.search.indexOf("v=1")!==-1),t=this,c.prototype.log=function(){var n;return n=Array.prototype.slice.call(arguments),n.unshift(this.constructor.name),t.log.apply(t,n)}}return t.prototype.ready=function(t){return null==t&&(t=function(){}),this.log("ready"),t()},t.prototype.initialize=function(t){var n,e,o,r,i,u;for(null==t&&(t={}),this.log("initialize",t),null==t.integrations&&(t.integrations=[]),u=t.integrations,e=0,i=u.length;e<i;e++)r=u[e],n=require("./integrations/"+r.type),o=new n(r),o.init(),o.load(),this.integrations.push(o);return this},t.prototype.call=function(t,n,e,o,r){var i,u,c,a;for(null==r&&(r=function(){}),this.log("call",t,n,e,o),a=this.integrations,i=0,c=a.length;i<c;i++)u=a[i],null!=u[t]?(u.log(t,n,e,o),u[t].call(u,n,e,o,r)):(u.log(null!=n?n:t,e,o),u.track.call(u,null!=n?n:t,e,o,r));return this},t.prototype.identify=function(t,n,e,o){return this.log("identify",t,n,e),this.call("identify",t,n,e,o)},t.prototype.track=function(t,n,e,o){var r;return this.log("track",t,n,e),r=t.replace(/\s+/g,""),r=r[0].toLowerCase()+r.substring(1),this.call(r,t,n,e,o)},t.prototype.page=function(t,n,e,o,r){return this.log("page",t,n,e,o),this.call("page",t,n,e,o,r)},t.prototype.debug=function(t){return null==t&&(t=!0),this._debug=t},t.prototype.log=function(){if(this._debug)return"undefined"!=typeof console&&null!==console?console.log.apply(console,arguments):void 0},t.prototype.alias=function(){},t.prototype.group=function(){},t.prototype.load=function(){},t.prototype.off=function(){},t.prototype.on=function(){},t.prototype.once=function(){},t.prototype.reset=function(){},t.prototype.trackClick=function(){},t.prototype.trackForm=function(){},t.prototype.trackLink=function(){},t.prototype.trackSubmit=function(){},t.prototype.user=function(){},t}()}),n.define("./integration",function(t,e,o,r,i){var u,c,a,l;l=n("./loaders/script"),a=n("./loaders/img"),c=n("./loaders/iframe"),t.exports=u=function(){function t(){}return t.prototype.init=function(){},t.prototype.load=function(t){if(null==t&&(t=function(){}),null!=this.src&&null!=this.src.type&&null!=this.src.url)switch(this.log("load",this.src),this.src.type){case"script":return l(this.src,t);case"img":return a(this.src,t);case"iframe":return c(this.src,t)}},t}()}),n.define("./loaders/script",function(t,e,o,r,i){var u;u=n("./utils").onload,t.exports=function(t,n){var e,o,r,i,c,a;if(c=document.createElement("script"),u(c,n),c.async=null!=(r=t.async)?r:1,c.src=t.url,null!=t.attrs){i=t.attrs;for(o in i)a=i[o],c.setAttribute(o,a)}return null!=t.text&&(c.text=""+t.text),e=document.head||document.getElementsByTagName("head")[0],e.parentNode.insertBefore(c,e),c}}),n.define("./utils",function(t,n,e,o,r){n.onload=function(t,n){var e,o;return e=function(t,n){return t.addEventListener("load",function(t,e){return n(null,e)},!1),t.addEventListener("error",function(e){var o;return o=new Error("failed to load the script '"+t.src+"'"),o.event=e,n(o)},!1)},o=function(t,n){return t.attachEvent("onreadystatechange",function(e){if(/complete|loaded/.test(t.readyState))return n(null,e)}),t.attachEvent("onerror",function(e){var o;return o=new Error("failed to load the script '"+t.src+"'"),o.event=e||window.event,n(o)})},t.addEventListener?e(t,n):o(t,n)}}),n.define("./loaders/img",function(t,e,o,r,i){var u;u=n("./utils").onload,t.exports=function(t,n){var e;return e=new Image,u(e,n),e.width=1,e.height=1,e.src=t.url,e}}),n.define("./loaders/iframe",function(t,e,o,r,i){var u;u=n("./utils").onload,t.exports=function(t,n){var e,o;return o=document.createElement("iframe"),u(o,n),o.width=1,o.height=1,o.style.display="none",o.src=t.url,e=document.getElementsByTagName("script")[0],e.parentNode.insertBefore(o,e),o}}),n.define("./integrations",function(t,e,o,r,i){t.exports={Custom:n("./integrations/custom"),FacebookPixel:n("./integrations/facebook-pixel"),FacebookConversions:n("./integrations/facebook-conversions"),GoogleAdWords:n("./integrations/google-adwords"),GoogleAnalytics:n("./integrations/google-analytics")}}),n.define("./integrations/custom",function(t,e,o,r,i){var u,c,a=function(t,n){function e(){this.constructor=t}for(var o in n)l.call(n,o)&&(t[o]=n[o]);return e.prototype=n.prototype,t.prototype=new e,t.__super__=n.prototype,t},l={}.hasOwnProperty;c=n("./integration"),t.exports=u=function(t){function n(t){this.opts=t,null==this.src&&(this.src=this.opts.src),this.fn=new Function(this.opts.code)}return a(n,t),n.prototype.track=function(t,n,e,o){var r;if(null==o&&(o=function(){}),t===this.opts.event)try{return this.fn(t,n,e,o)}catch(t){return r=t,this.log("Custom integration failed, "+r.toString())}},n}(c)}),n.define("./integrations/facebook-pixel",function(t,e,o,r,i){var u,c,a,l=function(t,n){function e(){this.constructor=t}for(var o in n)s.call(n,o)&&(t[o]=n[o]);return e.prototype=n.prototype,t.prototype=new e,t.__super__=n.prototype,t},s={}.hasOwnProperty;c=n("./integration"),a=function(t){return"string"==typeof t?t:"number"==typeof t?t.toFixed(2):void 0},t.exports=u=function(t){function n(t){this.opts=t}return l(n,t),n.prototype.src={type:"script",url:"//connect.facebook.net/en_US/fbevents.js"},n.prototype.init=function(){var t;if(null==window.fbq)return t=window.fbq=function(){t.callMethod?t.callMethod.apply(t,arguments):t.queue.push(arguments)},window._fbq||(window._fbq=t),t.push=t,t.loaded=!0,t.version="2.0",t.queue=[],t("init",this.opts.id),t("track","PageView")},n.prototype.page=function(t,n,e,o,r){return null==e&&(e={}),null==o&&(o={}),null==r&&(r=function(){}),fbq("track","ViewContent"),r(null)},n.prototype.track=function(t,n,e,o){switch(null==o&&(o=function(){}),t){case"Initiate Checkout":fbq("track","InitiateCheckout");break;case"Add Payment Info":fbq("track","AddPaymentInfo");break;case"Lead":fbq("track","Lead");break;case"Complete Registration":fbq("track","CompleteRegistration");break;case"Search":fbq("track","Search");break;case"Add to Wishlist":fbq("track","AddToWishList")}return o(null)},n.prototype.viewedProduct=function(t,n,e,o){return null==o&&(o=function(){}),fbq("track","ViewContent"),o(null)},n.prototype.addedProduct=function(t,n,e,o){return null==o&&(o=function(){}),fbq("track","AddToCart"),o(null)},n.prototype.completedOrder=function(t,n,e,o){var r;return null==o&&(o=function(){}),fbq("track","Purchase",{value:a(n.total),currency:null!=(r=n.currency)?r:"USD"}),o(null)},n}(c)}),n.define("./integrations/facebook-conversions",function(t,e,o,r,i){var u,c,a=function(t,n){function e(){this.constructor=t}for(var o in n)l.call(n,o)&&(t[o]=n[o]);return e.prototype=n.prototype,t.prototype=new e,t.__super__=n.prototype,t},l={}.hasOwnProperty;c=n("./integration"),t.exports=u=function(t){function n(t){this.opts=t}return a(n,t),n.prototype.src={type:"script",url:"//connect.facebook.net/en_US/fbds.js"},n.prototype.init=function(){if(null==window._fbq)return window._fbq=[]},n.prototype.load=function(){if("undefined"==typeof _fbq||null===_fbq||!_fbq.loaded)return n.__super__.load.apply(this,arguments),_fbq.loaded=!0},n.prototype.page=function(t,n,e,o,r){return 1===arguments.length&&(n=t),this.track(n,e,o,r)},n.prototype.track=function(t,n,e,o){var r,i,u,c,a,l,s;if(null==o&&(o=function(){}),t===this.opts.event)return i=this.opts.id,s=null!=(u=null!=(c=n.value)?c:this.opts.value)?u:"0.00",r=null!=(a=null!=(l=n.currency)?l:this.opts.currency)?a:"USD",_fbq.push(["track",i,{value:s,currency:r}])},n}(c)}),n.define("./integrations/google-adwords",function(t,e,o,r,i){var u,c,a=function(t,n){function e(){this.constructor=t}for(var o in n)l.call(n,o)&&(t[o]=n[o]);return e.prototype=n.prototype,t.prototype=new e,t.__super__=n.prototype,t},l={}.hasOwnProperty;c=n("./integration"),t.exports=u=function(t){function n(t){this.opts=t,this.queue=[]}return a(n,t),n.prototype.src={type:"script",url:"//www.googleadservices.com/pagead/conversion_async.js"},n.prototype.init=function(){if(null==window.google_trackConversion)return window.google_trackConversion=function(t){return function(n){return t.queue.push(n)}}(this)},n.prototype.load=function(t){return null==t&&(t=function(){}),n.__super__.load.call(this,function(n){return function(){var e,o,r,i;if(n.queue.length)for(i=n.queue,o=0,r=i.length;o<r;o++)e=i[o],google_trackConversion(e);return t(null)}}(this))},n.prototype.page=function(t,n,e,o,r){if(null==r&&(r=function(){}),1===arguments.length&&(n=t),n===this.opts.event)return google_trackConversion({google_conversion_id:this.opts.id,google_custom_params:e,google_remarketing_only:!0}),r(null)},n.prototype.track=function(t,n,e,o){if(null==o&&(o=function(){}),t===this.opts.event)return google_trackConversion({google_conversion_id:this.opts.id,google_custom_params:n,google_conversion_language:"en",google_conversion_format:"3",google_conversion_color:"ffffff",google_conversion_label:t,google_conversion_value:n.total,google_remarketing_only:!1}),o(null)},n}(c)}),n.define("./integrations/google-analytics",function(t,e,o,r,i){var u,c,a,l,s,p=function(t,n){function e(){this.constructor=t}for(var o in n)f.call(n,o)&&(t[o]=n[o]);return e.prototype=n.prototype,t.prototype=new e,t.__super__=n.prototype,t},f={}.hasOwnProperty;c=n("./integration"),l=function(t){return"string"==typeof t&&(t=t.indexOf(".")!==-1?Math.round(parseFloat(t,10)):parseInt(t,10)),t},a=function(t){return"string"==typeof t?t:"number"==typeof t?t.toFixed(2):void 0},s=function(t){var n,e,o;null==t&&(t={}),n={};for(e in t)o=t[e],null!=o&&(n[e]=o);return n},t.exports=u=function(t){function n(t){this.opts=t}return p(n,t),n.prototype.src={type:"script",url:"//www.google-analytics.com/analytics.js"},n.prototype.init=function(){return function(t,n,e,o,r,i,u){return t.GoogleAnalyticsObject=r,t[r]=t[r]||function(){(t[r].q=t[r].q||[]).push(arguments)},t[r].l=1*new Date}(window,document,"","","ga"),window.GoogleAnalyticsObject="ga",ga("create",this.opts.id,"auto")},n.prototype.addProduct=function(t){var n;return ga("ec:addProduct",s({id:null!=(n=t.id)?n:t.sku,brand:t.brand,category:t.category,coupon:t.coupon,currency:t.currency,name:t.name,price:a(t.price),quantity:t.quantity,variant:t.variant}))},n.prototype.setAction=function(t,n){return ga("ec:setAction",t,s(n))},n.prototype.sendEvent=function(t,n){var e,o,r,i,u;return null==n&&(n={}),o={eventAction:t},null!=n&&(o.eventCategory=n.category,o.eventLabel=n.label,o.eventValue=l(null!=(r=null!=(i=null!=(u=n.value)?u:n.total)?i:n.revenue)?r:0),o.nonInteraction=n.nonInteraction,null!=(e=n.campaign)&&(o.campaignName=e.name,o.campaignSource=e.source,o.campaignMedium=e.medium,o.campaignContent=e.content,o.campaignKeyword=e.term)),ga("send","event",s(o))},n.prototype.sendEEEvent=function(t,n){return null==n.category&&(n.category="EnhancedEcommerce"),this.sendEvent(t,n)},n.prototype.identify=function(t,n,e,o){return null==o&&(o=function(){}),ga("set","userId",t),o(null)},n.prototype.page=function(t,n,e,o,r){return null==e&&(e={}),null==o&&(o={}),null==r&&(r=function(){}),ga("set",s(o)),ga("send","pageview",s(o)),r(null)},n.prototype.track=function(t,n,e,o){return null==o&&(o=function(){}),this.sendEvent(t,n),o(null)},n.prototype.loadEnhancedEcommerce=function(t,n){var e;return null==n&&(n={}),this._enhancedEcommerceLoaded||(ga("require","ec"),this._enhancedEcommerceLoaded=!0),ga("set","&cu",null!=(e=n.currency)?e:"USD")},n.prototype.viewedProduct=function(t,n,e,o){return null==o&&(o=function(){}),this.loadEnhancedEcommerce(t,n),this.addProduct(n),this.setAction("detail",n),this.sendEEEvent(t,n),o(null)},n.prototype.addedProduct=function(t,n,e,o){return null==o&&(o=function(){}),this.loadEnhancedEcommerce(t,n),this.addProduct(n),this.setAction("add",n),this.sendEEEvent(t,n),o(null)},n.prototype.removedProduct=function(t,n,e,o){return null==o&&(o=function(){}),this.loadEnhancedEcommerce(t,n),this.addProduct(n),this.setAction("remove",n),this.sendEEEvent(t,n),o(null)},n.prototype.completedOrder=function(t,n,e,o){var r,i,u,c,l;if(null==o&&(o=function(){}),this.loadEnhancedEcommerce(t,n),null!=n.orderId&&null!=n.products){for(c=n.products,r=0,i=c.length;r<i;r++)u=c[r],this.addProduct(u);return this.setAction("purchase",{id:n.orderId,affiliation:n.affiliation,revenue:a(null!=(l=n.total)?l:n.revenue),tax:a(n.tax),shipping:a(n.shipping),coupon:n.coupon}),this.sendEEEvent(t,n),o(null)}},n.prototype.viewedCheckoutStep=function(t,n,e,o){var r;return null==o&&(o=function(){}),this.setAction("checkout",{steps:null!=(r=n.step)?r:1,option:e}),this.sendEEEvent(t,n),o(null)},n.prototype.completedCheckoutStep=function(t,n,e,o){var r;return null==o&&(o=function(){}),this.setAction("checkout_option",{steps:null!=(r=n.step)?r:1,option:e}),this.sendEEEvent(t,n),o(null)},n}(c)}),n.define("./index",function(t,e,o,r,i){t.exports={Analytics:n("./analytics"),Integration:n("./integration"),Integrations:n("./integrations")}});var analytics,item,method,ref,stub;for(stub=null!=(ref=window.analytics)?ref:[],window.analytics=analytics=new(require("./analytics")),stub.debug&&analytics.debug(),analytics.initialize({"integrations":[{"type":"google-analytics","id":"UA-85132684-1","values":{"viewedProduct":{},"addedProduct":{},"initiateCheckout":{},"addPaymentInfo":{}}},{"type":"facebook-pixel","id":"366194547064903","values":{"currency":"usd","viewedProduct":{},"addedProduct":{},"initiateCheckout":{},"addPaymentInfo":{}}}]});stub.length>0;)item=stub.shift(),method=item.shift(),null!=analytics[method]&&analytics[method].apply(analytics,item);setTimeout(function(){analytics.page()},3000);}).call(this,this);