@elgorditosalsero/react-gtm-hook
Advanced tools
Comparing version 2.6.0 to 2.7.1
@@ -32,3 +32,3 @@ import React, { Context, ReactNode } from 'react'; | ||
export declare const GTMContext: React.Context<ISnippetsParams | undefined>; | ||
export declare const GTMContextDispatch: React.Context<any>; | ||
export declare const GTMContextDispatch: React.Context<(({ dataLayerName, data }: import("./models/GoogleTagManager").ISendToGTM) => void) | undefined>; | ||
/** | ||
@@ -38,3 +38,3 @@ * The Google Tag Manager Provider | ||
declare function GTMProvider({ state, children }: GTMHookProviderProps): JSX.Element; | ||
declare function useGTMDispatch(): any; | ||
declare function useGTMDispatch(): ({ dataLayerName, data }: import("./models/GoogleTagManager").ISendToGTM) => void; | ||
export { GTMProvider, useGTMDispatch, sendToGTM }; |
@@ -39,4 +39,6 @@ /** | ||
injectScript?: boolean; | ||
/** Defaults to https://www.googletagmanager.com/gtm.js */ | ||
/** Defaults to https://www.googletagmanager.com */ | ||
customDomain?: string; | ||
/** Defaults to gtm.js */ | ||
customScriptName?: string; | ||
}; | ||
@@ -43,0 +45,0 @@ /** |
@@ -11,6 +11,5 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -22,6 +21,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -31,2 +28,3 @@ } | ||
var DEFAULT_DOMAIN = 'https://www.googletagmanager.com'; | ||
var DEFAULT_SCRIPT_NAME = 'gtm.js'; | ||
/** | ||
@@ -37,3 +35,2 @@ * Function to get and set dataLayer | ||
*/ | ||
var getDataLayerSnippet = function getDataLayerSnippet(dataLayer, dataLayerName) { | ||
@@ -43,3 +40,2 @@ if (dataLayerName === void 0) { | ||
} | ||
return "window." + dataLayerName + " = window." + dataLayerName + " || [];" + (dataLayer ? "window." + dataLayerName + ".push(" + JSON.stringify(dataLayer) + ")" : ''); | ||
@@ -53,3 +49,2 @@ }; | ||
*/ | ||
var getIframeSnippet = function getIframeSnippet(id, environment, customDomain) { | ||
@@ -59,11 +54,8 @@ if (customDomain === void 0) { | ||
} | ||
var params = ""; | ||
if (environment) { | ||
var gtm_auth = environment.gtm_auth, | ||
gtm_preview = environment.gtm_preview; | ||
gtm_preview = environment.gtm_preview; | ||
params = ">m_auth=" + gtm_auth + ">m_preview=" + gtm_preview + ">m_cookies_win=x"; | ||
} | ||
return "<iframe src=\"" + customDomain + "/ns.html?id=" + id + params + "\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\" id=\"tag-manager\"></iframe>"; | ||
@@ -75,20 +67,20 @@ }; | ||
* @param customDomain - Custom domain for gtm | ||
* @param customScriptName - Custom script file name for gtm | ||
* @param environment - The parameters to use a custom environment | ||
* @param id - The id of the container | ||
*/ | ||
var getGTMScript = function getGTMScript(dataLayerName, id, environment, customDomain) { | ||
var getGTMScript = function getGTMScript(dataLayerName, id, environment, customDomain, customScriptName) { | ||
if (customDomain === void 0) { | ||
customDomain = DEFAULT_DOMAIN; | ||
} | ||
if (customScriptName === void 0) { | ||
customScriptName = DEFAULT_SCRIPT_NAME; | ||
} | ||
var params = ""; | ||
if (environment) { | ||
var gtm_auth = environment.gtm_auth, | ||
gtm_preview = environment.gtm_preview; | ||
gtm_preview = environment.gtm_preview; | ||
params = "+\">m_auth=" + gtm_auth + ">m_preview=" + gtm_preview + ">m_cookies_win=x\""; | ||
} | ||
return "\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '" + customDomain + "/gtm.js?id='+i+dl" + params + ";f.parentNode.insertBefore(j,f);\n })(window,document,'script','" + dataLayerName + "','" + id + "');\n "; | ||
return "\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '" + customDomain + "/" + customScriptName + "?id='+i+dl" + params + ";f.parentNode.insertBefore(j,f);\n })(window,document,'script','" + dataLayerName + "','" + id + "');\n "; | ||
}; | ||
@@ -100,15 +92,11 @@ | ||
*/ | ||
var setupGTM = function setupGTM(params) { | ||
var getDataLayerScript = function getDataLayerScript() { | ||
var dataLayerScript = document.createElement('script'); | ||
if (params.nonce) { | ||
dataLayerScript.setAttribute('nonce', params.nonce); | ||
} | ||
dataLayerScript.innerHTML = getDataLayerSnippet(params.dataLayer, params.dataLayerName); | ||
return dataLayerScript; | ||
}; | ||
var getNoScript = function getNoScript() { | ||
@@ -119,14 +107,10 @@ var noScript = document.createElement('noscript'); | ||
}; | ||
var getScript = function getScript() { | ||
var script = document.createElement('script'); | ||
if (params.nonce) { | ||
script.setAttribute('nonce', params.nonce); | ||
} | ||
script.innerHTML = getGTMScript(params.dataLayerName, params.id, params.environment, params.customDomain); | ||
script.innerHTML = getGTMScript(params.dataLayerName, params.id, params.environment, params.customDomain, params.customScriptName); | ||
return script; | ||
}; | ||
return { | ||
@@ -146,11 +130,10 @@ getDataLayerScript: getDataLayerScript, | ||
*/ | ||
var initGTM = function initGTM(_ref) { | ||
var dataLayer = _ref.dataLayer, | ||
dataLayerName = _ref.dataLayerName, | ||
environment = _ref.environment, | ||
nonce = _ref.nonce, | ||
id = _ref.id, | ||
customDomain = _ref.customDomain; | ||
dataLayerName = _ref.dataLayerName, | ||
environment = _ref.environment, | ||
nonce = _ref.nonce, | ||
id = _ref.id, | ||
customDomain = _ref.customDomain, | ||
customScriptName = _ref.customScriptName; | ||
var gtm = setupGTM({ | ||
@@ -162,3 +145,4 @@ dataLayer: dataLayer, | ||
id: id, | ||
customDomain: customDomain | ||
customDomain: customDomain, | ||
customScriptName: customScriptName | ||
}); | ||
@@ -177,7 +161,5 @@ var dataLayerScript = gtm.getDataLayerScript(); | ||
*/ | ||
var sendToGTM = function sendToGTM(_ref2) { | ||
var dataLayerName = _ref2.dataLayerName, | ||
data = _ref2.data; | ||
data = _ref2.data; | ||
if (window[dataLayerName]) { | ||
@@ -193,3 +175,2 @@ window[dataLayerName].push(data); | ||
*/ | ||
var initialState = { | ||
@@ -206,6 +187,4 @@ dataLayer: undefined, | ||
*/ | ||
var GTMContext = /*#__PURE__*/React.createContext(initialState); | ||
var GTMContextDispatch = /*#__PURE__*/React.createContext(undefined); | ||
function dataReducer(state, data) { | ||
@@ -221,17 +200,11 @@ sendToGTM({ | ||
*/ | ||
function GTMProvider(_ref) { | ||
var state = _ref.state, | ||
children = _ref.children; | ||
children = _ref.children; | ||
var _useReducer = React.useReducer(dataReducer, _extends({}, initialState, state)), | ||
store = _useReducer[0], | ||
dispatch = _useReducer[1]; | ||
store = _useReducer[0], | ||
dispatch = _useReducer[1]; | ||
React.useEffect(function () { | ||
if (!state || state.injectScript == false) return; | ||
var mergedState = _extends({}, store, state); | ||
initGTM(mergedState); | ||
@@ -245,10 +218,7 @@ }, [JSON.stringify(state)]); | ||
} | ||
function useGTMDispatch() { | ||
var context = React.useContext(GTMContextDispatch); | ||
if (context === undefined) { | ||
throw new Error('dispatchGTMEvent must be used within a GTMProvider'); | ||
} | ||
return context; | ||
@@ -255,0 +225,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var a=function(e){var t=e.dataLayerName;window[t]?window[t].push(e.data):console.warn("dataLayer "+t+" does not exist, has script be initialized")},i={dataLayer:void 0,dataLayerName:"dataLayer",environment:void 0,nonce:void 0,id:"",injectScript:!0},o=t.createContext(i),d=t.createContext(void 0);function c(e,t){return a({data:t,dataLayerName:null==e?void 0:e.dataLayerName}),e}exports.GTMContext=o,exports.GTMContextDispatch=d,exports.GTMProvider=function(e){var a=e.state,s=e.children,u=t.useReducer(c,r({},i,a)),m=u[0],v=u[1];return t.useEffect((function(){a&&0!=a.injectScript&&function(e){var t,n=(t={dataLayer:e.dataLayer,dataLayerName:e.dataLayerName,environment:e.environment,nonce:e.nonce,id:e.id,customDomain:e.customDomain},{getDataLayerScript:function(){var e,n,r=document.createElement("script");return t.nonce&&r.setAttribute("nonce",t.nonce),r.innerHTML=(void 0===(n=t.dataLayerName)&&(n="dataLayer"),"window."+n+" = window."+n+" || [];"+((e=t.dataLayer)?"window."+n+".push("+JSON.stringify(e)+")":"")),r},getNoScript:function(){var e=document.createElement("noscript");return e.innerHTML=function(e,t,n){void 0===n&&(n="https://www.googletagmanager.com");var r="";return t&&(r=">m_auth="+t.gtm_auth+">m_preview="+t.gtm_preview+">m_cookies_win=x"),'<iframe src="'+n+"/ns.html?id="+e+r+'" height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>'}(t.id,t.environment,t.customDomain),e},getScript:function(){var e=document.createElement("script");return t.nonce&&e.setAttribute("nonce",t.nonce),e.innerHTML=function(e,t,n,r){void 0===r&&(r="https://www.googletagmanager.com");var a="";return n&&(a='+">m_auth='+n.gtm_auth+">m_preview="+n.gtm_preview+'>m_cookies_win=x"'),"\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '"+r+"/gtm.js?id='+i+dl"+a+";f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+e+"','"+t+"');\n "}(t.dataLayerName,t.id,t.environment,t.customDomain),e}}),r=n.getDataLayerScript(),a=n.getScript(),i=n.getNoScript();document.head.insertBefore(r,document.head.childNodes[0]),document.head.insertBefore(a,document.head.childNodes[1]),document.body.insertBefore(i,document.body.childNodes[0])}(r({},m,a))}),[JSON.stringify(a)]),n.createElement(o.Provider,{value:m},n.createElement(d.Provider,{value:v},s))},exports.initialState=i,exports.sendToGTM=a,exports.useGTMDispatch=function(){var e=t.useContext(d);if(void 0===e)throw new Error("dispatchGTMEvent must be used within a GTMProvider");return e}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var a=function(e){var t=e.dataLayerName;window[t]?window[t].push(e.data):console.warn("dataLayer "+t+" does not exist, has script be initialized")},i={dataLayer:void 0,dataLayerName:"dataLayer",environment:void 0,nonce:void 0,id:"",injectScript:!0},o=t.createContext(i),c=t.createContext(void 0);function d(e,t){return a({data:t,dataLayerName:null==e?void 0:e.dataLayerName}),e}exports.GTMContext=o,exports.GTMContextDispatch=c,exports.GTMProvider=function(e){var a=e.state,s=e.children,m=t.useReducer(d,r({},i,a)),u=m[0],p=m[1];return t.useEffect((function(){a&&0!=a.injectScript&&function(e){var t,n=(t={dataLayer:e.dataLayer,dataLayerName:e.dataLayerName,environment:e.environment,nonce:e.nonce,id:e.id,customDomain:e.customDomain,customScriptName:e.customScriptName},{getDataLayerScript:function(){var e,n,r=document.createElement("script");return t.nonce&&r.setAttribute("nonce",t.nonce),r.innerHTML=(void 0===(n=t.dataLayerName)&&(n="dataLayer"),"window."+n+" = window."+n+" || [];"+((e=t.dataLayer)?"window."+n+".push("+JSON.stringify(e)+")":"")),r},getNoScript:function(){var e=document.createElement("noscript");return e.innerHTML=function(e,t,n){void 0===n&&(n="https://www.googletagmanager.com");var r="";return t&&(r=">m_auth="+t.gtm_auth+">m_preview="+t.gtm_preview+">m_cookies_win=x"),'<iframe src="'+n+"/ns.html?id="+e+r+'" height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>'}(t.id,t.environment,t.customDomain),e},getScript:function(){var e=document.createElement("script");return t.nonce&&e.setAttribute("nonce",t.nonce),e.innerHTML=function(e,t,n,r,a){void 0===r&&(r="https://www.googletagmanager.com"),void 0===a&&(a="gtm.js");var i="";return n&&(i='+">m_auth='+n.gtm_auth+">m_preview="+n.gtm_preview+'>m_cookies_win=x"'),"\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '"+r+"/"+a+"?id='+i+dl"+i+";f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+e+"','"+t+"');\n "}(t.dataLayerName,t.id,t.environment,t.customDomain,t.customScriptName),e}}),r=n.getDataLayerScript(),a=n.getScript(),i=n.getNoScript();document.head.insertBefore(r,document.head.childNodes[0]),document.head.insertBefore(a,document.head.childNodes[1]),document.body.insertBefore(i,document.body.childNodes[0])}(r({},u,a))}),[JSON.stringify(a)]),n.createElement(o.Provider,{value:u},n.createElement(c.Provider,{value:p},s))},exports.initialState=i,exports.sendToGTM=a,exports.useGTMDispatch=function(){var e=t.useContext(c);if(void 0===e)throw new Error("dispatchGTMEvent must be used within a GTMProvider");return e}; | ||
//# sourceMappingURL=react-gtm-hook.cjs.production.min.js.map |
import React, { createContext, useReducer, useEffect, useContext } from 'react'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -14,6 +13,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -23,2 +20,3 @@ } | ||
var DEFAULT_DOMAIN = 'https://www.googletagmanager.com'; | ||
var DEFAULT_SCRIPT_NAME = 'gtm.js'; | ||
/** | ||
@@ -29,3 +27,2 @@ * Function to get and set dataLayer | ||
*/ | ||
var getDataLayerSnippet = function getDataLayerSnippet(dataLayer, dataLayerName) { | ||
@@ -35,3 +32,2 @@ if (dataLayerName === void 0) { | ||
} | ||
return "window." + dataLayerName + " = window." + dataLayerName + " || [];" + (dataLayer ? "window." + dataLayerName + ".push(" + JSON.stringify(dataLayer) + ")" : ''); | ||
@@ -45,3 +41,2 @@ }; | ||
*/ | ||
var getIframeSnippet = function getIframeSnippet(id, environment, customDomain) { | ||
@@ -51,11 +46,8 @@ if (customDomain === void 0) { | ||
} | ||
var params = ""; | ||
if (environment) { | ||
var gtm_auth = environment.gtm_auth, | ||
gtm_preview = environment.gtm_preview; | ||
gtm_preview = environment.gtm_preview; | ||
params = ">m_auth=" + gtm_auth + ">m_preview=" + gtm_preview + ">m_cookies_win=x"; | ||
} | ||
return "<iframe src=\"" + customDomain + "/ns.html?id=" + id + params + "\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\" id=\"tag-manager\"></iframe>"; | ||
@@ -67,20 +59,20 @@ }; | ||
* @param customDomain - Custom domain for gtm | ||
* @param customScriptName - Custom script file name for gtm | ||
* @param environment - The parameters to use a custom environment | ||
* @param id - The id of the container | ||
*/ | ||
var getGTMScript = function getGTMScript(dataLayerName, id, environment, customDomain) { | ||
var getGTMScript = function getGTMScript(dataLayerName, id, environment, customDomain, customScriptName) { | ||
if (customDomain === void 0) { | ||
customDomain = DEFAULT_DOMAIN; | ||
} | ||
if (customScriptName === void 0) { | ||
customScriptName = DEFAULT_SCRIPT_NAME; | ||
} | ||
var params = ""; | ||
if (environment) { | ||
var gtm_auth = environment.gtm_auth, | ||
gtm_preview = environment.gtm_preview; | ||
gtm_preview = environment.gtm_preview; | ||
params = "+\">m_auth=" + gtm_auth + ">m_preview=" + gtm_preview + ">m_cookies_win=x\""; | ||
} | ||
return "\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '" + customDomain + "/gtm.js?id='+i+dl" + params + ";f.parentNode.insertBefore(j,f);\n })(window,document,'script','" + dataLayerName + "','" + id + "');\n "; | ||
return "\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '" + customDomain + "/" + customScriptName + "?id='+i+dl" + params + ";f.parentNode.insertBefore(j,f);\n })(window,document,'script','" + dataLayerName + "','" + id + "');\n "; | ||
}; | ||
@@ -92,15 +84,11 @@ | ||
*/ | ||
var setupGTM = function setupGTM(params) { | ||
var getDataLayerScript = function getDataLayerScript() { | ||
var dataLayerScript = document.createElement('script'); | ||
if (params.nonce) { | ||
dataLayerScript.setAttribute('nonce', params.nonce); | ||
} | ||
dataLayerScript.innerHTML = getDataLayerSnippet(params.dataLayer, params.dataLayerName); | ||
return dataLayerScript; | ||
}; | ||
var getNoScript = function getNoScript() { | ||
@@ -111,14 +99,10 @@ var noScript = document.createElement('noscript'); | ||
}; | ||
var getScript = function getScript() { | ||
var script = document.createElement('script'); | ||
if (params.nonce) { | ||
script.setAttribute('nonce', params.nonce); | ||
} | ||
script.innerHTML = getGTMScript(params.dataLayerName, params.id, params.environment, params.customDomain); | ||
script.innerHTML = getGTMScript(params.dataLayerName, params.id, params.environment, params.customDomain, params.customScriptName); | ||
return script; | ||
}; | ||
return { | ||
@@ -138,11 +122,10 @@ getDataLayerScript: getDataLayerScript, | ||
*/ | ||
var initGTM = function initGTM(_ref) { | ||
var dataLayer = _ref.dataLayer, | ||
dataLayerName = _ref.dataLayerName, | ||
environment = _ref.environment, | ||
nonce = _ref.nonce, | ||
id = _ref.id, | ||
customDomain = _ref.customDomain; | ||
dataLayerName = _ref.dataLayerName, | ||
environment = _ref.environment, | ||
nonce = _ref.nonce, | ||
id = _ref.id, | ||
customDomain = _ref.customDomain, | ||
customScriptName = _ref.customScriptName; | ||
var gtm = setupGTM({ | ||
@@ -154,3 +137,4 @@ dataLayer: dataLayer, | ||
id: id, | ||
customDomain: customDomain | ||
customDomain: customDomain, | ||
customScriptName: customScriptName | ||
}); | ||
@@ -169,7 +153,5 @@ var dataLayerScript = gtm.getDataLayerScript(); | ||
*/ | ||
var sendToGTM = function sendToGTM(_ref2) { | ||
var dataLayerName = _ref2.dataLayerName, | ||
data = _ref2.data; | ||
data = _ref2.data; | ||
if (window[dataLayerName]) { | ||
@@ -185,3 +167,2 @@ window[dataLayerName].push(data); | ||
*/ | ||
var initialState = { | ||
@@ -198,6 +179,4 @@ dataLayer: undefined, | ||
*/ | ||
var GTMContext = /*#__PURE__*/createContext(initialState); | ||
var GTMContextDispatch = /*#__PURE__*/createContext(undefined); | ||
function dataReducer(state, data) { | ||
@@ -213,17 +192,11 @@ sendToGTM({ | ||
*/ | ||
function GTMProvider(_ref) { | ||
var state = _ref.state, | ||
children = _ref.children; | ||
children = _ref.children; | ||
var _useReducer = useReducer(dataReducer, _extends({}, initialState, state)), | ||
store = _useReducer[0], | ||
dispatch = _useReducer[1]; | ||
store = _useReducer[0], | ||
dispatch = _useReducer[1]; | ||
useEffect(function () { | ||
if (!state || state.injectScript == false) return; | ||
var mergedState = _extends({}, store, state); | ||
initGTM(mergedState); | ||
@@ -237,10 +210,7 @@ }, [JSON.stringify(state)]); | ||
} | ||
function useGTMDispatch() { | ||
var context = useContext(GTMContextDispatch); | ||
if (context === undefined) { | ||
throw new Error('dispatchGTMEvent must be used within a GTMProvider'); | ||
} | ||
return context; | ||
@@ -247,0 +217,0 @@ } |
@@ -10,3 +10,3 @@ import { ISendToGTM, ISnippetsParams } from '../models/GoogleTagManager'; | ||
*/ | ||
export declare const initGTM: ({ dataLayer, dataLayerName, environment, nonce, id, customDomain }: ISnippetsParams) => void; | ||
export declare const initGTM: ({ dataLayer, dataLayerName, environment, nonce, id, customDomain, customScriptName }: ISnippetsParams) => void; | ||
/** | ||
@@ -13,0 +13,0 @@ * Function to send the events to the GTM |
import { ICustomEnvironmentParams, IDataLayer, ISnippets, ISnippetsParams } from '../models/GoogleTagManager'; | ||
export declare const DEFAULT_DOMAIN = "https://www.googletagmanager.com"; | ||
export declare const DEFAULT_SCRIPT_NAME = "gtm.js"; | ||
/** | ||
@@ -20,5 +21,6 @@ * Function to get and set dataLayer | ||
* @param customDomain - Custom domain for gtm | ||
* @param customScriptName - Custom script file name for gtm | ||
* @param environment - The parameters to use a custom environment | ||
* @param id - The id of the container | ||
*/ | ||
export declare const getGTMScript: (dataLayerName: Pick<ISnippetsParams, 'dataLayerName'>['dataLayerName'], id: Pick<ISnippetsParams, 'id'>['id'], environment?: ICustomEnvironmentParams | undefined, customDomain?: ISnippetsParams['customDomain']) => string; | ||
export declare const getGTMScript: (dataLayerName: Pick<ISnippetsParams, 'dataLayerName'>['dataLayerName'], id: Pick<ISnippetsParams, 'id'>['id'], environment?: ICustomEnvironmentParams | undefined, customDomain?: ISnippetsParams['customDomain'], customScriptName?: ISnippetsParams['customScriptName']) => string; |
@@ -14,3 +14,3 @@ { | ||
"description": "Easily manage the Google Tag Manager via Hook", | ||
"version": "2.6.0", | ||
"version": "2.7.1", | ||
"license": "MIT", | ||
@@ -43,2 +43,3 @@ "main": "dist/index.js", | ||
"babel-plugin-module-resolver": "^4.1.0", | ||
"eslint-plugin-prettier": "3.4.1", | ||
"husky": "^7.0.4", | ||
@@ -45,0 +46,0 @@ "prettier": "^2.6.1", |
@@ -0,1 +1,3 @@ | ||
# MAINTAINERS WANTED, PLEASE REACH OUT IF YOU'RE INTERESTED | ||
<p align="center"> | ||
@@ -165,3 +167,4 @@ <img src="https://user-images.githubusercontent.com/65770455/82931604-76c14380-9f87-11ea-8d36-4ab2bc94b1d3.png" alt="React Google Tag Manager Hook" /> | ||
| injectScript | `Boolean` | **NO** | default(`true`): Decide if the GTM Script is injected, see #30. Also allows for delayed injection by toggling true later in flow | | ||
| customDomain | `String` | **NO** | default(`https://www.example.com`): Provide customDomain to use a custom GTM domain | | ||
| customDomain | `String` | **NO** | default(`https://www.googletagmanager.com`): Provide customDomain to use a custom GTM domain | | ||
| customScriptName | `String` | **NO** | default(`gtm.js`): Provide customScriptName to use custom file name | | ||
@@ -185,3 +188,3 @@ ### SentDataToGTM | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
@@ -195,16 +198,20 @@ | ||
<table> | ||
<tr> | ||
<td align="center"><a href="https://www.linkedin.com/in/guidoporcaro/"><img src="https://avatars2.githubusercontent.com/u/65770455?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Guido Porcaro</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://benyap.com"><img src="https://avatars3.githubusercontent.com/u/19235373?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Yap</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Documentation">📖</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://cristianlivella.com/"><img src="https://avatars.githubusercontent.com/u/27968888?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cristian Livella</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=cristianlivella" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/jafin"><img src="https://avatars.githubusercontent.com/u/127927?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jason Finch</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=jafin" title="Code">💻</a></td> | ||
<td align="center"><a href="https://segredo.dev/"><img src="https://avatars.githubusercontent.com/u/11761170?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Italo</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=iaurg" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/thecoder93"><img src="https://avatars.githubusercontent.com/u/3246694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gianluca La Manna</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=thecoder93" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://github.com/daisy1754"><img src="https://avatars.githubusercontent.com/u/980077?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kazuki</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=daisy1754" title="Code">💻</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://github.com/perfectial-stepan-mandryka"><img src="https://avatars.githubusercontent.com/u/95344107?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stepan Mandryka</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=perfectial-stepan-mandryka" title="Code">💻</a></td> | ||
<td align="center"><a href="http://simonsmith.io/"><img src="https://avatars.githubusercontent.com/u/360703?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Simon Smith</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=simonsmith" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://github.com/listiani13"><img src="https://avatars.githubusercontent.com/u/24470609?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Listiani</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Documentation">📖</a></td> | ||
</tr> | ||
<tbody> | ||
<tr> | ||
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/guidoporcaro/"><img src="https://avatars2.githubusercontent.com/u/65770455?v=4?s=100" width="100px;" alt="Guido Porcaro"/><br /><sub><b>Guido Porcaro</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=elgorditosalsero" title="Documentation">📖</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://benyap.com"><img src="https://avatars3.githubusercontent.com/u/19235373?v=4?s=100" width="100px;" alt="Ben Yap"/><br /><sub><b>Ben Yap</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Documentation">📖</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=benyap" title="Tests">⚠️</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://cristianlivella.com/"><img src="https://avatars.githubusercontent.com/u/27968888?v=4?s=100" width="100px;" alt="Cristian Livella"/><br /><sub><b>Cristian Livella</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=cristianlivella" title="Code">💻</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jafin"><img src="https://avatars.githubusercontent.com/u/127927?v=4?s=100" width="100px;" alt="Jason Finch"/><br /><sub><b>Jason Finch</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=jafin" title="Code">💻</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://segredo.dev/"><img src="https://avatars.githubusercontent.com/u/11761170?v=4?s=100" width="100px;" alt="Italo"/><br /><sub><b>Italo</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=iaurg" title="Code">💻</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/thecoder93"><img src="https://avatars.githubusercontent.com/u/3246694?v=4?s=100" width="100px;" alt="Gianluca La Manna"/><br /><sub><b>Gianluca La Manna</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=thecoder93" title="Documentation">📖</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/daisy1754"><img src="https://avatars.githubusercontent.com/u/980077?v=4?s=100" width="100px;" alt="Kazuki"/><br /><sub><b>Kazuki</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=daisy1754" title="Code">💻</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/perfectial-stepan-mandryka"><img src="https://avatars.githubusercontent.com/u/95344107?v=4?s=100" width="100px;" alt="Stepan Mandryka"/><br /><sub><b>Stepan Mandryka</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=perfectial-stepan-mandryka" title="Code">💻</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="http://simonsmith.io/"><img src="https://avatars.githubusercontent.com/u/360703?v=4?s=100" width="100px;" alt="Simon Smith"/><br /><sub><b>Simon Smith</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=simonsmith" title="Documentation">📖</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/listiani13"><img src="https://avatars.githubusercontent.com/u/24470609?v=4?s=100" width="100px;" alt="Listiani"/><br /><sub><b>Listiani</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=listiani13" title="Documentation">📖</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pkulcsarnr"><img src="https://avatars.githubusercontent.com/u/84968286?v=4?s=100" width="100px;" alt="pkulcsarnr"/><br /><sub><b>pkulcsarnr</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=pkulcsarnr" title="Code">💻</a> <a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=pkulcsarnr" title="Documentation">📖</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sin-to-jin"><img src="https://avatars.githubusercontent.com/u/5368888?v=4?s=100" width="100px;" alt="sin"/><br /><sub><b>sin</b></sub></a><br /><a href="https://github.com/elgorditosalsero/react-gtm-hook/commits?author=sin-to-jin" title="Code">💻</a></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
@@ -211,0 +218,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
73485
566
222
18