@analytics/google-tag-manager
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [0.4.0](https://github.com/DavidWells/analytics/compare/@analytics/google-tag-manager@0.3.1...@analytics/google-tag-manager@0.4.0) (2020-12-13) | ||
### Features | ||
* **google-tag-manager:** allow customScriptSrc ([78659c6](https://github.com/DavidWells/analytics/commit/78659c6)) | ||
* **google-tag-manager:** allow customScriptSrc - use custom script src from the config ([cc81706](https://github.com/DavidWells/analytics/commit/cc81706)) | ||
## [0.3.1](https://github.com/DavidWells/analytics/compare/@analytics/google-tag-manager@0.3.0...@analytics/google-tag-manager@0.3.1) (2020-12-12) | ||
@@ -8,0 +20,0 @@ |
@@ -53,2 +53,3 @@ var analyticsGtagManager = (function () { | ||
* @param {string} [pluginConfig.dataLayerName=dataLayer] - The optional name for dataLayer-object. Defaults to dataLayer. | ||
* @param {string} [pluginConfig.customScriptSrc] - Load Google Tag Manager script from a custom source | ||
* @return {object} Analytics plugin | ||
@@ -71,3 +72,4 @@ * @example | ||
var containerId = config.containerId, | ||
dataLayerName = config.dataLayerName; | ||
dataLayerName = config.dataLayerName, | ||
customScriptSrc = config.customScriptSrc; | ||
@@ -78,2 +80,4 @@ if (!containerId) { | ||
var scriptSrc = customScriptSrc || 'https://www.googletagmanager.com/gtm.js'; | ||
if (!scriptLoaded(containerId)) { | ||
@@ -91,3 +95,3 @@ /* eslint-disable */ | ||
j.async = true; | ||
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; | ||
j.src = "".concat(scriptSrc, "?id=") + i + dl; | ||
f.parentNode.insertBefore(j, f); | ||
@@ -94,0 +98,0 @@ })(window, document, 'script', dataLayerName, containerId); |
@@ -1,1 +0,1 @@ | ||
var analyticsGtagManager=function(){"use strict";function c(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),t.forEach(function(e){var t,a,n;t=r,n=o[a=e],a in t?Object.defineProperty(t,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[a]=n})}return r}var r,e={debug:!1,containerId:null,dataLayerName:"dataLayer",dataLayer:void 0};var n={};function o(e){var t=n[e];t||(t=new RegExp("googletagmanager\\.com\\/gtm\\.js.*[?&]id="+e),n[e]=t);var a=document.querySelectorAll("script[src]");return!!Object.keys(a).filter(function(e){return(a[e].src||"").match(t)}).length}return function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return{name:"google-tag-manager",config:c({},e,t),initialize:function(e){var t=e.config,a=t.containerId,n=t.dataLayerName;if(!a)throw new Error("No google tag manager containerId defined");o(a)||(function(e,t,a,n,r){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var o=t.getElementsByTagName(a)[0],i=t.createElement(a),c="dataLayer"!=n?"&l="+n:"";i.async=!0,i.src="https://www.googletagmanager.com/gtm.js?id="+r+c,o.parentNode.insertBefore(i,o)}(window,document,"script",n,a),r=n,t.dataLayer=window[n])},page:function(e){var t=e.payload,a=(e.options,e.instance,e.config);void 0!==a.dataLayer&&a.dataLayer.push(t.properties)},track:function(e){var t=e.payload,a=(e.options,e.config);if(void 0!==a.dataLayer){var n=t.anonymousId,r=t.userId,o=t.properties,i=o;r&&(i.userId=r),n&&(i.anonymousId=n),o.category||(i.category="All"),a.debug&&console.log("gtag push",c({event:t.event},i)),a.dataLayer.push(c({event:t.event},i))}},loaded:function(){var e=!!r&&!(!window[r]||Array.prototype.push===window[r].push);return o(t.containerId)&&e}}}}(); | ||
var analyticsGtagManager=function(){"use strict";function i(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),t.forEach(function(e){var t,a,r;t=n,r=o[a=e],a in t?Object.defineProperty(t,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[a]=r})}return n}var o,e={debug:!1,containerId:null,dataLayerName:"dataLayer",dataLayer:void 0};var r={};function c(e){var t=r[e];t||(t=new RegExp("googletagmanager\\.com\\/gtm\\.js.*[?&]id="+e),r[e]=t);var a=document.querySelectorAll("script[src]");return!!Object.keys(a).filter(function(e){return(a[e].src||"").match(t)}).length}return function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return{name:"google-tag-manager",config:i({},e,t),initialize:function(e){var t=e.config,a=t.containerId,r=t.dataLayerName,n=t.customScriptSrc;if(!a)throw new Error("No google tag manager containerId defined");var g=n||"https://www.googletagmanager.com/gtm.js";c(a)||(function(e,t,a,r,n){e[r]=e[r]||[],e[r].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var o=t.getElementsByTagName(a)[0],c=t.createElement(a),i="dataLayer"!=r?"&l="+r:"";c.async=!0,c.src="".concat(g,"?id=")+n+i,o.parentNode.insertBefore(c,o)}(window,document,"script",r,a),o=r,t.dataLayer=window[r])},page:function(e){var t=e.payload,a=(e.options,e.instance,e.config);void 0!==a.dataLayer&&a.dataLayer.push(t.properties)},track:function(e){var t=e.payload,a=(e.options,e.config);if(void 0!==a.dataLayer){var r=t.anonymousId,n=t.userId,o=t.properties,c=o;n&&(c.userId=n),r&&(c.anonymousId=r),o.category||(c.category="All"),a.debug&&console.log("gtag push",i({event:t.event},c)),a.dataLayer.push(i({event:t.event},c))}},loaded:function(){var e=!!o&&!(!window[o]||Array.prototype.push===window[o].push);return c(t.containerId)&&e}}}}(); |
@@ -52,2 +52,3 @@ 'use strict'; | ||
* @param {string} [pluginConfig.dataLayerName=dataLayer] - The optional name for dataLayer-object. Defaults to dataLayer. | ||
* @param {string} [pluginConfig.customScriptSrc] - Load Google Tag Manager script from a custom source | ||
* @return {object} Analytics plugin | ||
@@ -70,3 +71,4 @@ * @example | ||
var containerId = config.containerId, | ||
dataLayerName = config.dataLayerName; | ||
dataLayerName = config.dataLayerName, | ||
customScriptSrc = config.customScriptSrc; | ||
@@ -77,2 +79,4 @@ if (!containerId) { | ||
var scriptSrc = customScriptSrc || 'https://www.googletagmanager.com/gtm.js'; | ||
if (!scriptLoaded(containerId)) { | ||
@@ -90,3 +94,3 @@ /* eslint-disable */ | ||
j.async = true; | ||
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; | ||
j.src = "".concat(scriptSrc, "?id=") + i + dl; | ||
f.parentNode.insertBefore(j, f); | ||
@@ -93,0 +97,0 @@ })(window, document, 'script', dataLayerName, containerId); |
@@ -50,2 +50,3 @@ function _defineProperty(obj, key, value) { | ||
* @param {string} [pluginConfig.dataLayerName=dataLayer] - The optional name for dataLayer-object. Defaults to dataLayer. | ||
* @param {string} [pluginConfig.customScriptSrc] - Load Google Tag Manager script from a custom source | ||
* @return {object} Analytics plugin | ||
@@ -68,3 +69,4 @@ * @example | ||
var containerId = config.containerId, | ||
dataLayerName = config.dataLayerName; | ||
dataLayerName = config.dataLayerName, | ||
customScriptSrc = config.customScriptSrc; | ||
@@ -75,2 +77,4 @@ if (!containerId) { | ||
var scriptSrc = customScriptSrc || 'https://www.googletagmanager.com/gtm.js'; | ||
if (!scriptLoaded(containerId)) { | ||
@@ -88,3 +92,3 @@ /* eslint-disable */ | ||
j.async = true; | ||
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; | ||
j.src = "".concat(scriptSrc, "?id=") + i + dl; | ||
f.parentNode.insertBefore(j, f); | ||
@@ -91,0 +95,0 @@ })(window, document, 'script', dataLayerName, containerId); |
{ | ||
"name": "@analytics/google-tag-manager", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Google tag manager plugin for 'analytics' module", | ||
@@ -55,3 +55,3 @@ "projectMeta": { | ||
}, | ||
"gitHead": "747d4da09fc2f44e0f840edd8f0c6116b210b3a1" | ||
"gitHead": "0433bc41fc1f650eeed7d827361bebfe78d526fe" | ||
} |
@@ -85,4 +85,4 @@ <!-- | ||
- **[analytics.page](https://getanalytics.io/api/#analyticspage)** - Sends page views into Google Tag Manager | ||
- **[analytics.track](https://getanalytics.io/api/#analyticstrack)** - Track custom events and send to Google Tag Manager | ||
- **[analytics.page](https://getanalytics.io/api/#analyticspage)** - Sends page views into Google Tag Manager | ||
- **[analytics.track](https://getanalytics.io/api/#analyticstrack)** - Track custom events and send to Google Tag Manager | ||
@@ -112,2 +112,3 @@ ### Browser API | ||
| `dataLayerName` <br/>_optional_ - string| The optional name for dataLayer-object. Defaults to dataLayer. | | ||
| `customScriptSrc` <br/>_optional_ - string| Load Google Tag Manager script from a custom source | | ||
@@ -114,0 +115,0 @@ |
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
33439
464
288