@@ -18,9 +18,15 @@ class Config
1818 * General config
1919 */
2020 public const XML_PATH_EXTENSION_ENABLED = 'mfgoogletagmanager/general/enabled ' ;
21- public const XML_PATH_ACCOUNT_ID = 'mfgoogletagmanager/general/account_id ' ;
22- public const XML_PATH_CONTAINER_ID = 'mfgoogletagmanager/general/container_id ' ;
23- public const XML_PATH_PUBLIC_ID = 'mfgoogletagmanager/general/public_id ' ;
21+ public const XML_PATH_GTM_LOADER_TYPE = 'mfgoogletagmanager/general/loader_type ' ;
22+
23+ /**
24+ * Web Container config
25+ */
26+ public const XML_PATH_WEB_CONTAINER_ENABLED = 'mfgoogletagmanager/web_container/enabled ' ;
27+ public const XML_PATH_ACCOUNT_ID = 'mfgoogletagmanager/web_container/account_id ' ;
28+ public const XML_PATH_CONTAINER_ID = 'mfgoogletagmanager/web_container/container_id ' ;
29+ public const XML_PATH_WEB_PUBLIC_ID = 'mfgoogletagmanager/web_container/public_id ' ;
2430
2531 /**
2632 * Analytics config
@@ -68,6 +74,17 @@ public function isEnabled(string $storeId = null): bool
6874 $ this ->getPublicId ($ storeId );
6975 }
7076
77+ /**
78+ * Retrieve true if web container enabled
79+ *
80+ * @param string|null $storeId
81+ * @return bool
82+ */
83+ public function webContainerEnabled (string $ storeId = null ): bool
84+ {
85+ return (bool )$ this ->getConfig (self ::XML_PATH_WEB_CONTAINER_ENABLED , $ storeId );
86+ }
87+
7188 /**
7289 * Retrieve GTM account ID
7390 *
@@ -76,7 +93,7 @@ public function isEnabled(string $storeId = null): bool
7693 */
7794 public function getAccountId (string $ storeId = null ): string
7895 {
79- return trim (( string )$ this ->getConfig (self ::XML_PATH_ACCOUNT_ID , $ storeId) );
96+ return ( string )$ this ->getConfig (self ::XML_PATH_ACCOUNT_ID , $ storeId );
8097 }
8198
8299 /**
@@ -87,7 +104,7 @@ public function getAccountId(string $storeId = null): string
87104 */
88105 public function getContainerId (string $ storeId = null ): string
89106 {
90- return trim (( string )$ this ->getConfig (self ::XML_PATH_CONTAINER_ID , $ storeId) );
107+ return ( string )$ this ->getConfig (self ::XML_PATH_CONTAINER_ID , $ storeId );
91108 }
92109
93110 /**
@@ -98,7 +115,7 @@ public function getContainerId(string $storeId = null): string
98115 */
99116 public function getPublicId (string $ storeId = null ): string
100117 {
101- return trim (( string )$ this ->getConfig (self ::XML_PATH_PUBLIC_ID , $ storeId) );
118+ return ( string )$ this ->getConfig (self ::XML_PATH_WEB_PUBLIC_ID , $ storeId );
102119 }
103120
104121 /**
@@ -120,7 +137,7 @@ public function isAnalyticsEnabled(string $storeId = null): bool
120137 */
121138 public function getMeasurementId (string $ storeId = null ): string
122139 {
123- return trim (( string )$ this ->getConfig (self ::XML_PATH_ANALYTICS_MEASUREMENT_ID , $ storeId) );
140+ return ( string )$ this ->getConfig (self ::XML_PATH_ANALYTICS_MEASUREMENT_ID , $ storeId );
124141 }
125142
126143 /**
@@ -190,4 +207,13 @@ public function getConfig(string $path, string $storeId = null)
190207 {
191208 return $ this ->scopeConfig ->getValue ($ path , ScopeInterface::SCOPE_STORE , $ storeId );
192209 }
210+
211+ /**
212+ * @param string|null $storeId
213+ * @return int
214+ */
215+ public function getGTMLoaderType (string $ storeId = null ): string
216+ {
217+ return (string )$ this ->getConfig (self ::XML_PATH_GTM_LOADER_TYPE , $ storeId );
218+ }
193219}
0 commit comments