diff --git a/dist/angular-google-analytics.js b/dist/angular-google-analytics.js index f687345..a9f5fa7 100644 --- a/dist/angular-google-analytics.js +++ b/dist/angular-google-analytics.js @@ -1,6 +1,6 @@ /** * Angular Google Analytics - Easy tracking for your AngularJS application - * @version v0.0.6 - 2014-10-07 + * @version v0.0.6 - 2014-10-14 * @link http://github.com/revolunet/angular-google-analytics * @author Julien Bouquillon * @license MIT License, http://www.opensource.org/licenses/MIT @@ -125,6 +125,7 @@ angular.module('angular-google-analytics', []) if (!accountId) return; $window._gaq = []; $window._gaq.push(['_setAccount', accountId]); + if(domainName) $window._gaq.push(['_setDomainName', domainName]); if (enhancedLinkAttribution) { $window._gaq.push(['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js']); } @@ -135,7 +136,6 @@ angular.module('angular-google-analytics', []) $window._gaq.push(['_trackPageview']); } } - if(domainName) $window._gaq.push(['_setDomainName', domainName]); var gaSrc; if(displayFeatures) { gaSrc = ('https:' === document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; diff --git a/dist/angular-google-analytics.min.js b/dist/angular-google-analytics.min.js index 8c3ec45..4c73392 100644 --- a/dist/angular-google-analytics.min.js +++ b/dist/angular-google-analytics.min.js @@ -1,8 +1,8 @@ /** * Angular Google Analytics - Easy tracking for your AngularJS application - * @version v0.0.6 - 2014-10-07 + * @version v0.0.6 - 2014-10-14 * @link http://github.com/revolunet/angular-google-analytics * @author Julien Bouquillon * @license MIT License, http://www.opensource.org/licenses/MIT */ -"use strict";angular.module("angular-google-analytics",[]).provider("Analytics",function(){var e,t,n,a,r,i,s=!1,c=!0,o="",g=!1,u="$routeChangeSuccess",m="auto",l=!1,d=!1,_=!1,h=!1,f={allowLinker:!0};this._logs=[],this.setAccount=function(t){return e=t,!0},this.trackPages=function(e){return c=e,!0},this.trackPrefix=function(e){return o=e,!0},this.setDomainName=function(e){return n=e,!0},this.useDisplayFeatures=function(e){return t=!!e,!0},this.useAnalytics=function(e){return g=!!e,!0},this.useEnhancedLinkAttribution=function(e){return d=!!e,!0},this.useCrossDomainLinker=function(e){return h=!!e,!0},this.setCrossLinkDomains=function(e){return i=e,!0},this.setPageEvent=function(e){return u=e,!0},this.setCookieConfig=function(e){return m=e,!0},this.useECommerce=function(e){return l=!!e,!0},this.setRemoveRegExp=function(e){return e instanceof RegExp?(a=e,!0):!1},this.setExperimentId=function(e){return r=e,!0},this.ignoreFirstPageLoad=function(e){_=!!e},this.$get=["$document","$rootScope","$location","$window",function(p,k,v,w){function q(){if(e){w._gaq=[],w._gaq.push(["_setAccount",e]),d&&w._gaq.push(["_require","inpage_linkid","//www.google-analytics.com/plugins/ga/inpage_linkid.js"]),c&&!_&&(a?w._gaq.push(["_trackPageview",E()]):w._gaq.push(["_trackPageview"])),n&&w._gaq.push(["_setDomainName",n]);var r;r=t?("https:"===document.location.protocol?"https://":"http://")+"stats.g.doubleclick.net/dc.js":("https:"===document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js",function(){var e=p[0],t=e.createElement("script");t.type="text/javascript",t.async=!0,t.src=r;var n=e.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)}(r),s=!0}}function y(){if(!e)return console.warn("No account id set for Analytics.js");if(function(e,t,n,a,r,i,s){e.GoogleAnalyticsObject=r,e[r]=e[r]||function(){(e[r].q=e[r].q||[]).push(arguments)},e[r].l=1*new Date,i=t.createElement(n),s=t.getElementsByTagName(n)[0],i.async=1,i.src=a,s.parentNode.insertBefore(i,s)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),angular.isArray(e)?e.forEach(function(e){w.ga("create",e.tracker,m,{name:e.name})}):h?(w.ga("create",e,m,f),w.ga("require","linker"),i&&w.ga("linker:autoLink",i)):w.ga("create",e,m),t&&w.ga("require","displayfeatures"),c&&!_&&w.ga("send","pageview",E()),w.ga&&(l&&w.ga("require","ecommerce","ecommerce.js"),d&&w.ga("require","linkid","linkid.js"),r)){var n=document.createElement("script"),a=document.getElementsByTagName("script")[0];n.src="//www.google-analytics.com/cx/api.js?experiment="+r,a.parentNode.insertBefore(n,a)}}var E=function(){var e=v.path();return a?e.replace(a,""):e};this._log=function(){this._logs.push(arguments)},this._trackPage=function(t,n){n=n?n:p[0].title,c&&!g&&w._gaq?(w._gaq.push(["_set","title",n]),w._gaq.push(["_trackPageview",o+t]),this._log("_trackPageview",arguments)):c&&g&&w.ga&&(angular.isArray(e)?e.forEach(function(e){w.ga(e.name+".send","pageview",{page:o+t,title:n})}):w.ga("send","pageview",{page:o+t,title:n}),this._log("pageview",arguments))},this._trackEvent=function(e,t,n,a){!g&&w._gaq?(w._gaq.push(["_trackEvent",e,t,n,a]),this._log("trackEvent",arguments)):w.ga&&(w.ga("send","event",e,t,n,a),this._log("event",arguments))},this._addTrans=function(e,t,n,a,r,i,s,c,o){!g&&w._gaq?(w._gaq.push(["_addTrans",e,t,n,a,r,i,s,c]),this._log("_addTrans",arguments)):w.ga&&(l?(w.ga("ecommerce:addTransaction",{id:e,affiliation:t,revenue:n,tax:a,shipping:r,currency:o||"USD"}),this._log("ecommerce:addTransaction",arguments)):console.warn("ecommerce no set. Use AnalyticsProvider.setECommerce(true);"))},this._addItem=function(e,t,n,a,r,i){!g&&w._gaq?(w._gaq.push(["_addItem",e,t,n,a,r,i]),this._log("_addItem",arguments)):w.ga&&(w.ga("ecommerce:addItem",{id:e,name:n,sku:t,category:a,price:r,quantity:i}),this._log("ecommerce:addItem",arguments))},this._trackTrans=function(){!g&&w._gaq?(w._gaq.push(["_trackTrans"]),this._log("_trackTrans",arguments)):w.ga&&(w.ga("ecommerce:send"),this._log("ecommerce:send",arguments))},this._clearTrans=function(){w.ga&&(w.ga("ecommerce:clear"),this._log("ecommerce:clear",arguments))},this._send=function(e){w.ga&&(w.ga("send",e),this._log("send",e))},this._set=function(e,t){w.ga&&(w.ga("set",e,t),this._log("set",e,t))},g?y():q();var T=this;return c&&k.$on(u,function(){T._trackPage(E())}),{_logs:T._logs,cookieConfig:m,displayFeatures:t,ecommerce:l,enhancedLinkAttribution:d,getUrl:E,experimentId:r,ignoreFirstPageLoad:_,trackPage:function(e,t){T._trackPage(e,t)},trackEvent:function(e,t,n,a){T._trackEvent(e,t,n,a)},addTrans:function(e,t,n,a,r,i,s,c,o){T._addTrans(e,t,n,a,r,i,s,c,o)},addItem:function(e,t,n,a,r,i){T._addItem(e,t,n,a,r,i)},trackTrans:function(){T._trackTrans()},clearTrans:function(){T._clearTrans()},send:function(e){T._send(e)},set:function(e,t){T._set(e,t)}}}]}); \ No newline at end of file +"use strict";angular.module("angular-google-analytics",[]).provider("Analytics",function(){var a,b,c,d,e,f,g=!1,h=!0,i="",j=!1,k="$routeChangeSuccess",l="auto",m=!1,n=!1,o=!1,p=!1,q={allowLinker:!0};this._logs=[],this.setAccount=function(b){return a=b,!0},this.trackPages=function(a){return h=a,!0},this.trackPrefix=function(a){return i=a,!0},this.setDomainName=function(a){return c=a,!0},this.useDisplayFeatures=function(a){return b=!!a,!0},this.useAnalytics=function(a){return j=!!a,!0},this.useEnhancedLinkAttribution=function(a){return n=!!a,!0},this.useCrossDomainLinker=function(a){return p=!!a,!0},this.setCrossLinkDomains=function(a){return f=a,!0},this.setPageEvent=function(a){return k=a,!0},this.setCookieConfig=function(a){return l=a,!0},this.useECommerce=function(a){return m=!!a,!0},this.setRemoveRegExp=function(a){return a instanceof RegExp?(d=a,!0):!1},this.setExperimentId=function(a){return e=a,!0},this.ignoreFirstPageLoad=function(a){o=!!a},this.$get=["$document","$rootScope","$location","$window",function(r,s,t,u){function v(){if(a){u._gaq=[],u._gaq.push(["_setAccount",a]),c&&u._gaq.push(["_setDomainName",c]),n&&u._gaq.push(["_require","inpage_linkid","//www.google-analytics.com/plugins/ga/inpage_linkid.js"]),h&&!o&&u._gaq.push(d?["_trackPageview",x()]:["_trackPageview"]);var e;e=b?("https:"===document.location.protocol?"https://":"http://")+"stats.g.doubleclick.net/dc.js":("https:"===document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js",function(){var a=r[0],b=a.createElement("script");b.type="text/javascript",b.async=!0,b.src=e;var c=a.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)}(e),g=!0}}function w(){if(!a)return console.warn("No account id set for Analytics.js");if(function(a,b,c,d,e,f,g){a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),angular.isArray(a)?a.forEach(function(a){u.ga("create",a.tracker,l,{name:a.name})}):p?(u.ga("create",a,l,q),u.ga("require","linker"),f&&u.ga("linker:autoLink",f)):u.ga("create",a,l),b&&u.ga("require","displayfeatures"),h&&!o&&u.ga("send","pageview",x()),u.ga&&(m&&u.ga("require","ecommerce","ecommerce.js"),n&&u.ga("require","linkid","linkid.js"),e)){var c=document.createElement("script"),d=document.getElementsByTagName("script")[0];c.src="//www.google-analytics.com/cx/api.js?experiment="+e,d.parentNode.insertBefore(c,d)}}var x=function(){var a=t.path();return d?a.replace(d,""):a};this._log=function(){this._logs.push(arguments)},this._trackPage=function(b,c){c=c?c:r[0].title,h&&!j&&u._gaq?(u._gaq.push(["_set","title",c]),u._gaq.push(["_trackPageview",i+b]),this._log("_trackPageview",arguments)):h&&j&&u.ga&&(angular.isArray(a)?a.forEach(function(a){u.ga(a.name+".send","pageview",{page:i+b,title:c})}):u.ga("send","pageview",{page:i+b,title:c}),this._log("pageview",arguments))},this._trackEvent=function(a,b,c,d){!j&&u._gaq?(u._gaq.push(["_trackEvent",a,b,c,d]),this._log("trackEvent",arguments)):u.ga&&(u.ga("send","event",a,b,c,d),this._log("event",arguments))},this._addTrans=function(a,b,c,d,e,f,g,h,i){!j&&u._gaq?(u._gaq.push(["_addTrans",a,b,c,d,e,f,g,h]),this._log("_addTrans",arguments)):u.ga&&(m?(u.ga("ecommerce:addTransaction",{id:a,affiliation:b,revenue:c,tax:d,shipping:e,currency:i||"USD"}),this._log("ecommerce:addTransaction",arguments)):console.warn("ecommerce no set. Use AnalyticsProvider.setECommerce(true);"))},this._addItem=function(a,b,c,d,e,f){!j&&u._gaq?(u._gaq.push(["_addItem",a,b,c,d,e,f]),this._log("_addItem",arguments)):u.ga&&(u.ga("ecommerce:addItem",{id:a,name:c,sku:b,category:d,price:e,quantity:f}),this._log("ecommerce:addItem",arguments))},this._trackTrans=function(){!j&&u._gaq?(u._gaq.push(["_trackTrans"]),this._log("_trackTrans",arguments)):u.ga&&(u.ga("ecommerce:send"),this._log("ecommerce:send",arguments))},this._clearTrans=function(){u.ga&&(u.ga("ecommerce:clear"),this._log("ecommerce:clear",arguments))},this._send=function(a){u.ga&&(u.ga("send",a),this._log("send",a))},this._set=function(a,b){u.ga&&(u.ga("set",a,b),this._log("set",a,b))},j?w():v();var y=this;return h&&s.$on(k,function(){y._trackPage(x())}),{_logs:y._logs,cookieConfig:l,displayFeatures:b,ecommerce:m,enhancedLinkAttribution:n,getUrl:x,experimentId:e,ignoreFirstPageLoad:o,trackPage:function(a,b){y._trackPage(a,b)},trackEvent:function(a,b,c,d){y._trackEvent(a,b,c,d)},addTrans:function(a,b,c,d,e,f,g,h,i){y._addTrans(a,b,c,d,e,f,g,h,i)},addItem:function(a,b,c,d,e,f){y._addItem(a,b,c,d,e,f)},trackTrans:function(){y._trackTrans()},clearTrans:function(){y._clearTrans()},send:function(a){y._send(a)},set:function(a,b){y._set(a,b)}}}]}); \ No newline at end of file diff --git a/src/angular-google-analytics.js b/src/angular-google-analytics.js index 304e546..5817096 100644 --- a/src/angular-google-analytics.js +++ b/src/angular-google-analytics.js @@ -118,6 +118,7 @@ angular.module('angular-google-analytics', []) if (!accountId) return; $window._gaq = []; $window._gaq.push(['_setAccount', accountId]); + if(domainName) $window._gaq.push(['_setDomainName', domainName]); if (enhancedLinkAttribution) { $window._gaq.push(['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js']); } @@ -128,7 +129,6 @@ angular.module('angular-google-analytics', []) $window._gaq.push(['_trackPageview']); } } - if(domainName) $window._gaq.push(['_setDomainName', domainName]); var gaSrc; if(displayFeatures) { gaSrc = ('https:' === document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';