react-google-tag-manager
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -11,9 +11,10 @@ 'use strict'; | ||
function buildParts(_ref) { | ||
var id = _ref.id; | ||
var _ref$dataLayerName = _ref.dataLayerName; | ||
var dataLayerName = _ref$dataLayerName === undefined ? 'dataLayer' : _ref$dataLayerName; | ||
var _ref$additionalEvents = _ref.additionalEvents; | ||
var additionalEvents = _ref$additionalEvents === undefined ? {} : _ref$additionalEvents; | ||
var _ref$scheme = _ref.scheme; | ||
var scheme = _ref$scheme === undefined ? '' : _ref$scheme; | ||
var id = _ref.id, | ||
_ref$dataLayerName = _ref.dataLayerName, | ||
dataLayerName = _ref$dataLayerName === undefined ? 'dataLayer' : _ref$dataLayerName, | ||
_ref$additionalEvents = _ref.additionalEvents, | ||
additionalEvents = _ref$additionalEvents === undefined ? {} : _ref$additionalEvents, | ||
_ref$scheme = _ref.scheme, | ||
scheme = _ref$scheme === undefined ? '' : _ref$scheme, | ||
previewVariables = _ref.previewVariables; | ||
@@ -26,3 +27,3 @@ if (id === undefined) { | ||
var script = '\n (function(w,d,s,l,i){w[l]=w[l]||[];\n w[l].push({\'gtm.start\': new Date().getTime(),event:\'gtm.js\', ' + convertToKeyValueString(additionalEvents) + '});\n var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';\n j.async=true;j.src=\'' + scheme + '//www.googletagmanager.com/gtm.js?id=\'+i+dl;\n f.parentNode.insertBefore(j,f);\n })(window,document,\'script\',\'' + dataLayerName + '\',\'' + id + '\');'; | ||
var script = '\n (function(w,d,s,l,i){w[l]=w[l]||[];\n w[l].push({\'gtm.start\': new Date().getTime(),event:\'gtm.js\', ' + convertToKeyValueString(additionalEvents) + '});\n var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';\n j.async=true;j.src=\'' + scheme + '//www.googletagmanager.com/gtm.js?id=\'+i+dl\n +' + (previewVariables ? previewVariables : '') + ';\n f.parentNode.insertBefore(j,f);\n })(window,document,\'script\',\'' + dataLayerName + '\',\'' + id + '\');'; | ||
@@ -29,0 +30,0 @@ return { |
{ | ||
"name": "react-google-tag-manager", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "This package contains a react based implementation for Google's Tag Manager snippet.", | ||
@@ -47,3 +47,3 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"react": "^0.14.0 || ^15.0.0" | ||
"react": "^0.14.0 || ^15.0.0 || ^16.0.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "files": [ |
@@ -48,3 +48,4 @@ [![NPM Version](https://img.shields.io/npm/v/react-google-tag-manager.svg?style=flat)](https://www.npmjs.org/package/react-google-tag-manager) | ||
dataLayerName: this.props.dataLayerName || 'dataLayer', | ||
additionalEvents: this.props.additionalEvents || {} | ||
additionalEvents: this.props.additionalEvents || {}, | ||
previewVariables: this.props.previewVariables || false, | ||
}); | ||
@@ -67,2 +68,3 @@ | ||
additionalEvents: React.PropTypes.object, | ||
previewVariables: React.PropTypes.string, | ||
scriptId: React.PropTypes.string | ||
@@ -83,3 +85,3 @@ }; | ||
<GoogleTagManager gtmId='GTM-12345' scriptId='gtm-script-container' dataLayerName='dl-backup' additionalEvents={event} /> | ||
<GoogleTagManager gtmId='GTM-12345' scriptId='gtm-script-container' dataLayerName='dl-backup' additionalEvents={event} previewVariables='' /> | ||
``` | ||
@@ -95,6 +97,7 @@ | ||
| `scriptId` | no | `react-google-tag-manager-gtm` | | ||
| `previewVariables` | no | `false` | | ||
## Notes: | ||
* The `componentDidMount` part is required is required as React the script contents itself would not be executed otherwise on the client side | ||
* The `componentDidMount` part is required as the script contents itself would not be executed otherwise on the client side | ||
* As `eval` can be used to do harm, make sure that you are understanding what you are doing here and read through the script that is evaluated | ||
@@ -101,0 +104,0 @@ * Additionally this module exports `noScriptAsHTML()` and `scriptAsHTML()` which return a simple HTML string |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
9756
57
108
1