@analytics/google-analytics
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.0.5](https://github.com/DavidWells/analytics/compare/@analytics/google-analytics@1.0.4...@analytics/google-analytics@1.0.5) (2022-11-09) | ||
### Bug Fixes | ||
* pre-installed gtag causes analytics.js plugin to not initialize ([fd10ab2](https://github.com/DavidWells/analytics/commit/fd10ab2ebabf73beb6242a59b2a04a0af035044e)) | ||
## [1.0.4](https://github.com/DavidWells/analytics/compare/@analytics/google-analytics@1.0.3...@analytics/google-analytics@1.0.4) (2022-11-09) | ||
@@ -8,0 +19,0 @@ |
@@ -67,6 +67,6 @@ var analyticsGa = (function (exports) { | ||
* @param {object} pluginConfig - Plugin settings | ||
* @param {string|array} pluginConfig.measurementIds - Google Analytics MEASUREMENT IDs | ||
* @param {string[]} pluginConfig.measurementIds - Google Analytics MEASUREMENT IDs | ||
* @param {boolean} [pluginConfig.debug] - Enable Google Analytics debug mode | ||
* @param {string} [pluginConfig.dataLayerName=ga4DataLayer] - The optional name for dataLayer object. Defaults to ga4DataLayer. | ||
* @param {string} [pluginConfig.gtagName=gtag] - The optional name for dataLayer object. Defaults to ga4DataLayer. | ||
* @param {string} [pluginConfig.gtagName=gtag] - The optional name for dataLayer object. Defaults to `gtag`. | ||
* @param {boolean} [pluginConfig.gtagConfig.anonymize_ip] - Enable [Anonymizing IP addresses](https://bit.ly/3c660Rd) sent to Google Analytics. | ||
@@ -108,7 +108,11 @@ * @param {object} [pluginConfig.gtagConfig.cookie_domain] - Additional cookie properties for configuring the [ga cookie](https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#configuring_cookie_field_settings) | ||
if (!scriptLoaded(customScriptSrc || gtagScriptSource)) { | ||
var customLayerName = dataLayerName ? "&l=".concat(dataLayerName) : ''; | ||
/* If other gtags are loaded already, add ours anyway */ | ||
var customLayerName = dataLayerName ? "&l=".concat(dataLayerName) : ""; | ||
var src = customScriptSrc || "".concat(gtagScriptSource, "?id=").concat(measurementIds[0]).concat(customLayerName); | ||
if (!scriptLoaded(src)) { | ||
var script = document.createElement('script'); | ||
script.async = true; | ||
script.src = customScriptSrc || "".concat(gtagScriptSource, "?id=").concat(measurementIds[0]).concat(customLayerName); | ||
script.src = src; | ||
document.body.appendChild(script); | ||
@@ -115,0 +119,0 @@ } |
@@ -1,1 +0,1 @@ | ||
var analyticsGa=function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r={},o="https://www.googletagmanager.com/gtag/js",i={debug_mode:!1,send_page_view:!1,anonymize_ip:!1,allow_google_signals:!0,allow_ad_personalization_signals:!0,cookie_flags:""},c={gtagName:"gtag",dataLayerName:"ga4DataLayer",measurementIds:[],gtagConfig:i};function g(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=0,a=s(e.measurementIds),g=n(n({},c),e);return{name:"google-analytics",config:g,initialize:function(e){var t=e.config,c=e.instance,g=t.dataLayerName,s=t.customScriptSrc,d=t.gtagName,l=t.gtagConfig,p=t.debug;if(!u(s||o)){var w=g?"&l=".concat(g):"",f=document.createElement("script");f.async=!0,f.src=s||"".concat(o,"?id=").concat(a[0]).concat(w),document.body.appendChild(f)}window[g]||(window[g]=window[g]||[],window[d]=function(){window[g].push(arguments)},window[d]("js",new Date));var m=n(n({},i),l||{});!0===p?m.debug_mode=!0:delete m.debug_mode;var v=(c.user()||{}).traits||{};Object.keys(v).length&&window[d]("set","user_properties",v);for(var y=0;y<a.length;y++)r[a[y]]||(window[d]("config",a[y],m),r[a[y]]=!0)},identify:function(e){var t=e.payload,n=e.config.gtagName;window[n]&&a.length&&(t.userId&&window[n]("set",{user_id:t.userId}),Object.keys(t.traits).length&&window[n]("set","user_properties",t.traits))},page:function(e){var r=e.payload,o=e.config,i=e.instance,c=o.gtagName,g=o.gtagConfig;if(window[c]&&a.length){var s=r.properties,u=s.send_to,l=i.getState("context.campaign"),p={page_title:s.title,page_location:s.url,page_path:s.path||document.location.pathname,page_hash:s.hash,page_search:s.page_search,page_referrer:s.referrer},w=d(l),f=n(n(n({},u?{send_to:u}:{}),p),w);g&&g.send_page_view&&0===t||window[c]("event","page_view",f),t++}},track:function(e){var t=e.payload,r=e.config,o=e.instance,i=t.properties,c=t.event,g=o.getState("context.campaign"),s=r.gtagName;if(window[s]&&a.length){var u=d(g),l=n(n({},i),u);window[s]("event",c,l)}},loaded:function(){var e=g.dataLayerName,t=g.customScriptSrc,n=e&&window[e]&&Array.prototype.push===window[e].push;return u(t||o)&&n},methods:{addTag:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};window[g.gtagName]&&(window[g.gtagName]("config",e,t),a&&!a.includes(e)&&(a=a.concat(e)))},disable:function(e){for(var t=e?s(e):a,n=0;n<a.length;n++){var r=a[n];t.includes(r)&&(window["ga-disable-".concat(r)]=!0)}},enable:function(e){for(var t=e?s(e):a,n=0;n<a.length;n++){var r=a[n];t.includes(r)&&(window["ga-disable-".concat(r)]=!1)}}}}}function s(e){if(!e)throw new Error("No GA Measurement ID defined");if(Array.isArray(e))return e;if("string"==typeof e)return[e];throw new Error("GA Measurement ID must be string or array of strings")}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={},n=e.id,a=e.name,r=e.source,o=e.medium,i=e.content,c=e.keyword;return n&&(t.campaignId=n),a&&(t.campaignName=a),r&&(t.campaignSource=r),o&&(t.campaignMedium=o),i&&(t.campaignContent=i),c&&(t.campaignKeyword=c),t}function u(e){var t=document.querySelectorAll("script[src]"),n=new RegExp("^".concat(e));return Boolean(Object.values(t).filter((function(e){return n.test(e.src)})).length)}var l=g,p=g;return e.default=l,e.init=p,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var analyticsGa=function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r={},o="https://www.googletagmanager.com/gtag/js",i={debug_mode:!1,send_page_view:!1,anonymize_ip:!1,allow_google_signals:!0,allow_ad_personalization_signals:!0,cookie_flags:""},c={gtagName:"gtag",dataLayerName:"ga4DataLayer",measurementIds:[],gtagConfig:i};function g(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=0,a=s(e.measurementIds),g=n(n({},c),e);return{name:"google-analytics",config:g,initialize:function(e){var t=e.config,c=e.instance,g=t.dataLayerName,s=t.customScriptSrc,d=t.gtagName,l=t.gtagConfig,p=t.debug,w=g?"&l=".concat(g):"",f=s||"".concat(o,"?id=").concat(a[0]).concat(w);if(!u(f)){var m=document.createElement("script");m.async=!0,m.src=f,document.body.appendChild(m)}window[g]||(window[g]=window[g]||[],window[d]=function(){window[g].push(arguments)},window[d]("js",new Date));var v=n(n({},i),l||{});!0===p?v.debug_mode=!0:delete v.debug_mode;var y=(c.user()||{}).traits||{};Object.keys(y).length&&window[d]("set","user_properties",y);for(var h=0;h<a.length;h++)r[a[h]]||(window[d]("config",a[h],v),r[a[h]]=!0)},identify:function(e){var t=e.payload,n=e.config.gtagName;window[n]&&a.length&&(t.userId&&window[n]("set",{user_id:t.userId}),Object.keys(t.traits).length&&window[n]("set","user_properties",t.traits))},page:function(e){var r=e.payload,o=e.config,i=e.instance,c=o.gtagName,g=o.gtagConfig;if(window[c]&&a.length){var s=r.properties,u=s.send_to,l=i.getState("context.campaign"),p={page_title:s.title,page_location:s.url,page_path:s.path||document.location.pathname,page_hash:s.hash,page_search:s.page_search,page_referrer:s.referrer},w=d(l),f=n(n(n({},u?{send_to:u}:{}),p),w);g&&g.send_page_view&&0===t||window[c]("event","page_view",f),t++}},track:function(e){var t=e.payload,r=e.config,o=e.instance,i=t.properties,c=t.event,g=o.getState("context.campaign"),s=r.gtagName;if(window[s]&&a.length){var u=d(g),l=n(n({},i),u);window[s]("event",c,l)}},loaded:function(){var e=g.dataLayerName,t=g.customScriptSrc,n=e&&window[e]&&Array.prototype.push===window[e].push;return u(t||o)&&n},methods:{addTag:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};window[g.gtagName]&&(window[g.gtagName]("config",e,t),a&&!a.includes(e)&&(a=a.concat(e)))},disable:function(e){for(var t=e?s(e):a,n=0;n<a.length;n++){var r=a[n];t.includes(r)&&(window["ga-disable-".concat(r)]=!0)}},enable:function(e){for(var t=e?s(e):a,n=0;n<a.length;n++){var r=a[n];t.includes(r)&&(window["ga-disable-".concat(r)]=!1)}}}}}function s(e){if(!e)throw new Error("No GA Measurement ID defined");if(Array.isArray(e))return e;if("string"==typeof e)return[e];throw new Error("GA Measurement ID must be string or array of strings")}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={},n=e.id,a=e.name,r=e.source,o=e.medium,i=e.content,c=e.keyword;return n&&(t.campaignId=n),a&&(t.campaignName=a),r&&(t.campaignSource=r),o&&(t.campaignMedium=o),i&&(t.campaignContent=i),c&&(t.campaignKeyword=c),t}function u(e){var t=document.querySelectorAll("script[src]"),n=new RegExp("^".concat(e));return Boolean(Object.values(t).filter((function(e){return n.test(e.src)})).length)}var l=g,p=g;return e.default=l,e.init=p,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -68,6 +68,6 @@ 'use strict'; | ||
* @param {object} pluginConfig - Plugin settings | ||
* @param {string|array} pluginConfig.measurementIds - Google Analytics MEASUREMENT IDs | ||
* @param {string[]} pluginConfig.measurementIds - Google Analytics MEASUREMENT IDs | ||
* @param {boolean} [pluginConfig.debug] - Enable Google Analytics debug mode | ||
* @param {string} [pluginConfig.dataLayerName=ga4DataLayer] - The optional name for dataLayer object. Defaults to ga4DataLayer. | ||
* @param {string} [pluginConfig.gtagName=gtag] - The optional name for dataLayer object. Defaults to ga4DataLayer. | ||
* @param {string} [pluginConfig.gtagName=gtag] - The optional name for dataLayer object. Defaults to `gtag`. | ||
* @param {boolean} [pluginConfig.gtagConfig.anonymize_ip] - Enable [Anonymizing IP addresses](https://bit.ly/3c660Rd) sent to Google Analytics. | ||
@@ -109,7 +109,11 @@ * @param {object} [pluginConfig.gtagConfig.cookie_domain] - Additional cookie properties for configuring the [ga cookie](https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#configuring_cookie_field_settings) | ||
if (!scriptLoaded(customScriptSrc || gtagScriptSource)) { | ||
var customLayerName = dataLayerName ? "&l=".concat(dataLayerName) : ''; | ||
/* If other gtags are loaded already, add ours anyway */ | ||
var customLayerName = dataLayerName ? "&l=".concat(dataLayerName) : ""; | ||
var src = customScriptSrc || "".concat(gtagScriptSource, "?id=").concat(measurementIds[0]).concat(customLayerName); | ||
if (!scriptLoaded(src)) { | ||
var script = document.createElement('script'); | ||
script.async = true; | ||
script.src = customScriptSrc || "".concat(gtagScriptSource, "?id=").concat(measurementIds[0]).concat(customLayerName); | ||
script.src = src; | ||
document.body.appendChild(script); | ||
@@ -116,0 +120,0 @@ } |
@@ -64,6 +64,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
* @param {object} pluginConfig - Plugin settings | ||
* @param {string|array} pluginConfig.measurementIds - Google Analytics MEASUREMENT IDs | ||
* @param {string[]} pluginConfig.measurementIds - Google Analytics MEASUREMENT IDs | ||
* @param {boolean} [pluginConfig.debug] - Enable Google Analytics debug mode | ||
* @param {string} [pluginConfig.dataLayerName=ga4DataLayer] - The optional name for dataLayer object. Defaults to ga4DataLayer. | ||
* @param {string} [pluginConfig.gtagName=gtag] - The optional name for dataLayer object. Defaults to ga4DataLayer. | ||
* @param {string} [pluginConfig.gtagName=gtag] - The optional name for dataLayer object. Defaults to `gtag`. | ||
* @param {boolean} [pluginConfig.gtagConfig.anonymize_ip] - Enable [Anonymizing IP addresses](https://bit.ly/3c660Rd) sent to Google Analytics. | ||
@@ -105,7 +105,11 @@ * @param {object} [pluginConfig.gtagConfig.cookie_domain] - Additional cookie properties for configuring the [ga cookie](https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#configuring_cookie_field_settings) | ||
if (!scriptLoaded(customScriptSrc || gtagScriptSource)) { | ||
var customLayerName = dataLayerName ? "&l=".concat(dataLayerName) : ''; | ||
/* If other gtags are loaded already, add ours anyway */ | ||
var customLayerName = dataLayerName ? "&l=".concat(dataLayerName) : ""; | ||
var src = customScriptSrc || "".concat(gtagScriptSource, "?id=").concat(measurementIds[0]).concat(customLayerName); | ||
if (!scriptLoaded(src)) { | ||
var script = document.createElement('script'); | ||
script.async = true; | ||
script.src = customScriptSrc || "".concat(gtagScriptSource, "?id=").concat(measurementIds[0]).concat(customLayerName); | ||
script.src = src; | ||
document.body.appendChild(script); | ||
@@ -112,0 +116,0 @@ } |
{ | ||
"name": "@analytics/google-analytics", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Google analytics v4 plugin for 'analytics' module", | ||
@@ -56,3 +56,3 @@ "projectMeta": { | ||
}, | ||
"gitHead": "8151c6195808ab69f2fecd54a6878b961947bd71" | ||
"gitHead": "b4e38881b569d289c7d2fa606d18e8ea32497ae6" | ||
} |
@@ -113,6 +113,6 @@ <!-- | ||
|:---------------------------|:-----------| | ||
| `measurementIds` <br/>**required** - string| Google Analytics MEASUREMENT IDs | | ||
| `measurementIds` <br/>**required** - `Array.<string>`| Google Analytics MEASUREMENT IDs | | ||
| `debug` <br/>_optional_ - boolean| Enable Google Analytics debug mode | | ||
| `dataLayerName` <br/>_optional_ - string| The optional name for dataLayer object. Defaults to ga4DataLayer. | | ||
| `gtagName` <br/>_optional_ - string| The optional name for dataLayer object. Defaults to ga4DataLayer. | | ||
| `gtagName` <br/>_optional_ - string| The optional name for dataLayer object. Defaults to `gtag`. | | ||
| `gtagConfig.anonymize_ip` <br/>_optional_ - boolean| Enable [Anonymizing IP addresses](https://bit.ly/3c660Rd) sent to Google Analytics. | | ||
@@ -119,0 +119,0 @@ | `gtagConfig.cookie_domain` <br/>_optional_ - object| Additional cookie properties for configuring the [ga cookie](https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#configuring_cookie_field_settings) | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68324
938