diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d8bc222..f2366adb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,8 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [3.4.0] - 19 June 2023
### Added
-- Delay loading GTM until user interaction is triggered
+- Option to delay loading GTM until user interaction is triggered
## [3.3.4] - 16 June 2023
### Fixed
diff --git a/Config/Config.php b/Config/Config.php
index 7bc0554d..1fa166a7 100644
--- a/Config/Config.php
+++ b/Config/Config.php
@@ -80,6 +80,16 @@ public function isDebug(): bool
return (bool)$this->getModuleConfigValue('debug');
}
+ /**
+ * Wait for user interaction to start
+ *
+ * @return bool
+ */
+ public function waitForUserInteraction(): bool
+ {
+ return (bool)$this->getModuleConfigValue('wait_for_ui');
+ }
+
/**
* Check whether mouse clicks are debugged as well
*
diff --git a/composer.json b/composer.json
index 759168f0..21826bc6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "yireo/magento2-googletagmanager2",
- "version": "3.3.4",
+ "version": "3.4.0",
"license": "OSL-3.0",
"type": "magento2-module",
"homepage": "https://www.yireo.com/software/magento-extensions/googletagmanager2",
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index f7733ffa..a2ba31fe 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -53,6 +53,13 @@
1
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
+ 1
+
+
Maximum number of products to load in a specific category overview. 0 to disable
diff --git a/etc/config.xml b/etc/config.xml
index 55b73d84..1ae1def3 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -6,6 +6,7 @@
0
0
+ 0
3
material
id,name
diff --git a/view/frontend/templates/script.phtml b/view/frontend/templates/script.phtml
index bef59d06..9191ba42 100644
--- a/view/frontend/templates/script.phtml
+++ b/view/frontend/templates/script.phtml
@@ -29,7 +29,7 @@ $config = $block->getConfig();
events.forEach(function (eventType) {
window.addEventListener(eventType, initYireoGoogleTagManager2, {once: true, passive: true})
})
- })(['keydown', 'mouseover', 'scroll', 'touchstart', 'wheel']);
+ })([waitForUserInteraction() === false) : ?>'load', 'keydown', 'mouseover', 'scroll', 'touchstart', 'wheel']);
isDebug()): ?>