Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-google-tag-manager

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-tag-manager - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

17

lib/build_parts.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc