diff --git a/Block/DataLayer.php b/Block/DataLayer.php
index 35a2d45..c94558b 100755
--- a/Block/DataLayer.php
+++ b/Block/DataLayer.php
@@ -78,6 +78,15 @@ public function getCookieRestrictionName($store_id = null)
}
}
+ /**
+ * @param null $store_id
+ * @return bool
+ */
+ public function isExternal($store_id = null)
+ {
+ return (int) $this->_gtmHelper->isExternal($store_id);
+ }
+
/**
* @param null $store_id
* @return int
diff --git a/Block/GtmCode.php b/Block/GtmCode.php
index 27b1e46..a974059 100755
--- a/Block/GtmCode.php
+++ b/Block/GtmCode.php
@@ -59,6 +59,17 @@ public function getEmbeddedAccountId()
$this->getAccountId() . $this->_gtmHelper->getMultiContainerCode() : $this->getAccountId();
}
+ /**
+ * If the GTM should be loaded externally by an third party,
+ * like an GDPR service, this function will return true
+ * and false otherwise
+ *
+ * @return bool
+ */
+ public function isExternal(){
+ return $this->_gtmHelper->isExternal();
+ }
+
/**
* Render tag manager JS
*
diff --git a/Helper/Data.php b/Helper/Data.php
index c4a6906..f61dc1d 100755
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -63,6 +63,22 @@ public function isEnabled($store_id = null)
return $accountId && $active;
}
+ /**
+ * Whether Tag Manager should be loaded
+ * by an external third party app
+ *
+ * @param null $store_id
+ * @return bool
+ */
+ public function isExternal($store_id = null)
+ {
+ return $this->scopeConfig->getValue(
+ 'googletagmanager/general/external',
+ ScopeInterface::SCOPE_STORE,
+ $store_id
+ );
+ }
+
/**
* @param null $store_id
* @return string
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 253422b..8a247f1 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -55,12 +55,24 @@
Magento\Config\Model\Config\Source\Yesno
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
+ If you like to include GTM by your self due to an external gdpr solution for example,
+ you need to set this to "Yes" and include GTM like described by your provider.
+
+
+ 1
+
+
e.g GTM-XXXXXX
required-entry validate-no-html-tags
1
+ 0
@@ -68,6 +80,7 @@
Magento\Config\Model\Config\Source\Yesno
1
+ 0
@@ -75,20 +88,24 @@
MagePal\GoogleTagManager\Block\Adminhtml\System\Config\Form\Field\ItemVariantFormat
1
+ 0
1
-
Magento\Config\Model\Config\Source\Yesno
1
+ 0
+
+ 0
+
Magento\Config\Model\Config\Source\Yesno
diff --git a/etc/config.xml b/etc/config.xml
index da7d070..e72d7f5 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -14,6 +14,7 @@
0
2
0
+ 0
0
diff --git a/view/frontend/templates/iframe.phtml b/view/frontend/templates/iframe.phtml
index ec06c3d..fc2c05e 100755
--- a/view/frontend/templates/iframe.phtml
+++ b/view/frontend/templates/iframe.phtml
@@ -8,7 +8,14 @@
/** @var $block MagePal\GoogleTagManager\Block\GtmCode **/
?>
-
-
-
+isExternal()): ?>
+
+
+
+
\ No newline at end of file
diff --git a/view/frontend/templates/js.phtml b/view/frontend/templates/js.phtml
index 4569b4b..78de937 100755
--- a/view/frontend/templates/js.phtml
+++ b/view/frontend/templates/js.phtml
@@ -15,7 +15,7 @@ $containerCode = $block->getEmbeddedCode();
-
isGdprEnabled() || !$block->addJsInHead()): ?>