Skip to content

Commit 506c08a

Browse files
committed
refactor: only pass preventAutoBlock through
1 parent 5a89bd7 commit 506c08a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/initialization.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var initialization = {
6464
containerId,
6565
common.customDataLayerName,
6666
previewUrl,
67-
common.settings
67+
common.settings.preventAutoBlock
6868
);
6969
}
7070

@@ -92,7 +92,12 @@ var initialization = {
9292
},
9393
};
9494

95-
function initializeContainer(containerId, dataLayerName, previewUrl, settings) {
95+
function initializeContainer(
96+
containerId,
97+
dataLayerName,
98+
previewUrl,
99+
preventAutoBlock
100+
) {
96101
var url = 'https://www.googletagmanager.com/gtm.js';
97102

98103
// If Settings contains previewUrl, we should tack that onto the gtm snippet
@@ -107,12 +112,12 @@ function initializeContainer(containerId, dataLayerName, previewUrl, settings) {
107112

108113
url += '&l=' + dataLayerName;
109114

110-
loadSnippet(url, dataLayerName, settings);
115+
loadSnippet(url, dataLayerName, preventAutoBlock);
111116

112117
return true;
113118
}
114119

115-
function loadSnippet(url, dataLayerName, settings) {
120+
function loadSnippet(url, dataLayerName, preventAutoBlock) {
116121
window[dataLayerName].push({
117122
'gtm.start': new Date().getTime(),
118123
event: 'gtm.js',
@@ -122,7 +127,7 @@ function loadSnippet(url, dataLayerName, settings) {
122127
gTagScript.type = 'text/javascript';
123128
gTagScript.async = true;
124129
gTagScript.src = url;
125-
if (settings.preventAutoBlock === 'True') {
130+
if (preventAutoBlock === 'True') {
126131
gTagScript.setAttributeNode(
127132
window.document.createAttribute('data-ot-ignore')
128133
);

0 commit comments

Comments
 (0)