(function(){"use strict";u8.Crm.GoogleAnalyticsProvider=function(e){$.extend(this,$.extend({},u8.Crm.GoogleAnalyticsProvider.defaults,e))};u8.Crm.GoogleAnalyticsProvider.makeClass({name:"GoogleAnalyticsProvider"});u8.Crm.GoogleAnalyticsProvider.defaults={customDimInfoarea:u8.session.webConfigValues.get("GoogleAnalytics.CustomDimension.Infoarea","dimension1"),customDimView:u8.session.webConfigValues.get("GoogleAnalytics.CustomDimension.View","dimension2"),customDimVersion:u8.session.webConfigValues.get("GoogleAnalytics.CustomDimension.CRMVersion","dimension3"),customDimInstanceID:u8.session.webConfigValues.get("GoogleAnalytics.CustomDimension.InstanceID","dimension4"),customDimUserID:u8.session.webConfigValues.get("GoogleAnalytics.CustomDimension.UserID","dimension5"),sendUserID:u8.session.webConfigValues.getBoolean("GoogleAnalytics.SendUserID",false),trackerEnabled:u8.session.webConfigValues.getBoolean("GoogleAnalytics.MainTrackerEnabled",false),customerTrackerID:u8.session.webConfigValues.get("GoogleAnalytics.CustomerTrackerID","UA-77264536-1")};$.extend(u8.Crm.GoogleAnalyticsProvider.prototype,{sendCRMDataToGA:function(e,s){if(this.trackerEnabled===true){if(u8.session&&u8.session.environment){if(!u8.session.environment.isEnterpriseVersion){this.sendToGAServerStandard(e,s)}else{this.sendToGAServerEnterprise(e,s)}}}},sendToGAServerStandard:function(e,s){if(u8.session&&u8.session.webConfigValues){var n=u8.session.webConfigValues["GoogleAnalytics.CRMInstanceID"];var i=u8.services.clientStorage.getItem("CRMVersion");var o=u8.services.clientStorage.getItem("CRMUserIDHash");(function(e,s,n,i,o,t,a){e["GoogleAnalyticsObject"]=o;e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date;t=s.createElement(n),a=s.getElementsByTagName(n)[0];t.async=1;t.src=i;a.parentNode.insertBefore(t,a)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");ga("create",this.customerTrackerID,"auto");ga("set",this.customDimInfoarea,e);ga("set",this.customDimView,s);ga("set",this.customDimVersion,i);ga("set",this.customDimInstanceID,n);ga("set",this.customDimUserID,o);ga("send","pageview")}},sendToGAServerEnterprise:function(e,s){if(u8.session&&u8.session.webConfigValues){var n=u8.session.webConfigValues["GoogleAnalytics.CRMInstanceID"];var i=u8.services.clientStorage.getItem("CRMVersion");var o=u8.services.clientStorage.getItem("CRMUserIDHash");(function(e,s,n,i,o,t,a){e["GoogleAnalyticsObject"]=o;e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date;t=s.createElement(n),a=s.getElementsByTagName(n)[0];t.async=1;t.src=i;a.parentNode.insertBefore(t,a)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");ga("create",this.customerTrackerID,"auto");ga("set",this.customDimInfoarea,e);ga("set",this.customDimView,s);ga("set",this.customDimVersion,i);ga("set",this.customDimInstanceID,n);if(this.sendUserID===true){ga("set",this.customDimUserID,o)}ga("send","pageview")}},getCRMVersion:function(){if(window.navigator&&window.navigator.userAgent){var e={userAgent:window.navigator.userAgent,userName:$v("userName"),phoneVersion:null,text:null};var s;var n=u8.services.clientStorage;try{u8.request("AdministrationChannel.GetSystemInfo",{options:e},function(e,i){s=i.response||{};if(n&&s&&s.version&&s.version.version){n.setItem("CRMVersion",s.version.version);n.save()}},true)}catch(e){}}},getMD5Hash:function(e){var s=$.md5(e);return s}});u8.services.add("googleAnalyticsProvider",u8.Crm.GoogleAnalyticsProvider)})();