Index: /mods/wpsg_mod_statistics.class.php
===================================================================
--- /mods/wpsg_mod_statistics.class.php	(revision 8313)
+++ /mods/wpsg_mod_statistics.class.php	(revision 8314)
@@ -519,8 +519,77 @@
 			}
 
-			if ((int)$this->shop->get_option('wpsg_mod_statistics_google_active') == 1)
-			{
-				$this->simulateUrl = $this->shop->getURL(wpsg_ShopController::URL_BASKET).'?wpsg_done';
-				add_action('wp_footer', array($this, 'get_googleanalytics_html'), 100);
+			if ($this->shop->get_option('wpsg_mod_statistics_google_ecommerce') == '1')
+			{
+
+				if (!empty($done_view['basket']['coupon']['0']['code'])) $coupon_code = $done_view['basket']['coupon']['0']['code'];
+				else $coupon_code = false;
+
+				$products = '';
+				foreach($done_view['basket']['produkte'] as $p) {
+
+					$oProduct = wpsg_product::getInstance($p['id']);
+					$productCat = '';
+
+					if ($this->shop->hasMod('wpsg_mod_produktartikel')) 
+					{
+
+						$categoryID = $oProduct->getPostID();
+						$terms = get_the_terms($categoryID, get_taxonomies());
+
+						if ($terms) 
+						{
+
+							$termNames = array(); 
+							foreach ($terms as $term) $termNames[] = $term->name;
+
+							for ($i = 0; $i < 5; $i++) 
+							{
+								
+								if (isset($termNames[$i])) $productCat .= 'item_category'.($i+1).': "'.$termNames[$i].'", ';
+								else $productCat .= 'item_category'.($i+1).': "false", ';
+								
+							}
+
+						}
+
+					} else $productCat = 'item_category: "false",';
+
+					if ($this->shop->hasMod('wpsg_mod_productvariants')) $arVariInfo = $this->shop->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['product_key']));
+					else $arVariInfo = '"false"';
+
+					$products .= '{
+						item_id: "'. $p['id'] .'",
+						item_name: "'. $p['name'] .'",
+						affiliation: "false",
+						coupon: "false", 
+						discount: false, 
+						index: '. $p['product_index'] .',
+						item_brand: "false",
+						'. $productCat .' // maximal 5 Porduktkategorien - API limitierung
+						item_list_id: "false",
+						item_list_name: "false",
+						item_variant: "'. $arVariInfo['key'] .'", 
+						location_id: "false",
+						price: '. $p['preis_brutto'] .',
+						quantity: '. $p['menge'] .'
+					},';
+
+				}
+				$products = rtrim($products, ',');
+
+				echo '<script type="text/javascript">';
+
+					echo 'gtag("event", "purchase", {
+						transaction_id: "'. $done_view['o_id'] .'",
+						value: '. wpsg_tf($done_view['basket']['sum']['preis_gesamt_brutto']) .',
+						tax: '. wpsg_tf($done_view['basket']['sum']['mwst']) .',
+						shipping: '. wpsg_tf($done_view['basket']['sum']['preis_shipping_brutto']) .',
+						currency: "'. $this->shop->get_option('wpsg_currency') .'",
+						coupon: "'. $coupon_code .'", // maximal 1 CouponCode API limitierung
+						items: ['. $products .']
+					});';
+
+				echo '</script>';
+
 			}
 			
@@ -556,67 +625,100 @@
 		public function wp_head()
 		{
-
-			// https://developer.matomo.org/guides/tracking-javascript-guide
-			
-			if (!$this->usePiwik()) return false;
-
-			echo '<script type="text/javascript"> window._paq = []; </script>';
-
-			if ($this->shop->get_option('wpsg_mod_statistics_piwik_trackingcode') == '1')
-			{
-			
-				$url = $this->shop->get_option('wpsg_mod_statistics_piwik_url');
-				
-				echo '
-					<!-- Piwik Library -->	
-					<script type="text/javascript">
-
-						var protocol = document.location.protocol;
-						var pkBaseURL = protocol + "//'.$url.'/";
-
-						var scriptElement = document.createElement("script");
-						scriptElement.type = "text/javascript";
-						scriptElement.src = unescape(pkBaseURL + "matomo.js");
-
-						var firstScriptElement = document.getElementsByTagName("script")[0];
-						var parentElement = firstScriptElement.parentNode;
-						parentElement.appendChild(scriptElement);
-
-					</script>
-					<!-- End Piwik Library -->	
-				';
-
-				echo '
-					<!-- Piwik Tracking Code -->				
-					<script type="text/javascript">
-						try {
+			
+			if ($this->usePiwik() || $this->useGA4())
+			{
+
+				if ($this->usePiwik()) 
+				{
+
+					// https://developer.matomo.org/guides/tracking-javascript-guide
+					echo '<script type="text/javascript"> window._paq = []; </script>';
+
+					if ($this->shop->get_option('wpsg_mod_statistics_piwik_trackingcode') == '1')
+					{
+					
+						$url = $this->shop->get_option('wpsg_mod_statistics_piwik_url');
 						
-							_paq.push(["setTrackerUrl", pkBaseURL + "matomo.php"]);
-							_paq.push(["setSiteId", '.$this->shop->get_option('wpsg_mod_statistics_piwik_SiteId').']);
-
-						} catch(err) { }
-					</script>
-					<!-- End Piwik Tracking Code -->
-				';
-
-			}
-			
-			if ($this->shop->get_option('wpsg_mod_statistics_piwik_generel') == '1')
-			{
-
-				echo '
-					<!-- Piwik Protokollierung -->				
-					<script type="text/javascript">
-						try {
-
-							_paq.push(["trackPageView"]);
-							_paq.push(["enableLinkTracking"]);
-
-						} catch(err) { }
-					</script>
-					<!-- End Piwik Protokollierung -->
-				';
-				
-			}
+						echo '
+							<!-- Matomo Library -->	
+							<script type="text/javascript">
+
+								var protocol = document.location.protocol;
+								var pkBaseURL = protocol + "//'.$url.'/";
+
+								var scriptElement = document.createElement("script");
+								scriptElement.type = "text/javascript";
+								scriptElement.src = unescape(pkBaseURL + "matomo.js");
+
+								var firstScriptElement = document.getElementsByTagName("script")[0];
+								var parentElement = firstScriptElement.parentNode;
+								parentElement.appendChild(scriptElement);
+
+							</script>
+							<!-- End Matomo Library -->	
+						';
+
+						echo '
+							<!-- Piwik Matomo Code -->				
+							<script type="text/javascript">
+								try {
+								
+									_paq.push(["setTrackerUrl", pkBaseURL + "matomo.php"]);
+									_paq.push(["setSiteId", '.$this->shop->get_option('wpsg_mod_statistics_piwik_SiteId').']);
+
+								} catch(err) { }
+							</script>
+							<!-- End Matomo Tracking Code -->
+						';
+
+					}
+				
+					if ($this->shop->get_option('wpsg_mod_statistics_piwik_generel') == '1')
+					{
+
+						echo '
+							<!-- Matomo Protokollierung -->				
+							<script type="text/javascript">
+								try {
+
+									_paq.push(["trackPageView"]);
+									_paq.push(["enableLinkTracking"]);
+
+								} catch(err) { }
+							</script>
+							<!-- End Matomo Protokollierung -->
+						';
+						
+					}
+
+				} 
+
+				if ($this->useGA4())
+				{
+
+					// https://developers.google.com/analytics/devguides/collection/ga4/set-up-ecommerce
+					if ($this->shop->get_option('wpsg_mod_statistics_google_active') == '1')
+					{
+
+						$tag_id = $this->shop->get_option('wpsg_mod_statistics_google_tracking_code');
+				
+						echo '
+							<script async src="https://www.googletagmanager.com/gtag/js?id='.$tag_id.'"></script>
+							<script>
+								window.dataLayer = window.dataLayer || [];
+								function gtag(){ dataLayer.push(arguments); }
+								gtag("js", new Date());
+						
+								gtag("config", "'.$tag_id.'", { "debug_mode": true });
+							</script>
+						';
+
+					}
+
+				} 
+
+			}
+			else return false;
+
 			
 		} // public function wp_head()
@@ -756,9 +858,4 @@
 			
 			add_action('wp_dashboard_setup', array($this, 'wpsg_statistics_add_dashboard_widgets')); // Hint: For Multisite Network Admin Dashboard use wp_network_dashboard_setup instead of wp_dashboard_setup.	
-			
-			if ((int)$this->shop->get_option('wpsg_mod_statistics_google_active') == 1 && !isset($_GET['wpsg_done']))
-			{
-				add_action('wp_footer', array($this, 'get_googleanalytics_html'), 100);
-			}
 
 			add_action('wp_footer', array($this, 'productCat_bottom'));
@@ -921,28 +1018,28 @@
 			{
 				 				
-/*
-				$o = wpsg_getStr($this->shop->view['filter']['order']);
-				$s = wpsg_getStr($this->shop->view['filter']['sort']);
-				$r = wpsg_getStr($this->shop->view['standardFilter'][wpsg_getStr($this->shop->view['filter']['related'])]['point']);
-				$p = $this->shop->view['standardFilter'][$this->shop->view['filter']['standard']]['point'];
-				
-				//$this->shop->view['chart']['data'] = 
-				//$objchartClass->$chartFunction($this->shop->view['standardFilter'][$this->shop->view['filter']['standard']]['point'], 
-				//array('relatedpoint' => $this->shop->view['standardFilter'][wpsg_getStr($this->shop->view['filter']['related'])]['point'], 
-				//      'order' => wpsg_getStr($this->shop->view['filter']['order']), 
-				//      'sort' => wpsg_getStr($this->shop->view['filter']['sort'])));
-				
-				$this->shop->view['chart']['data'] = $objchartClass->$chartFunction($p, array('relatedpoint' => $r, 'order' => $o, 'sort' => $s));
-				
-				//if ((array_key_exists('related', $this->shop->view['filter'])) && ($this->shop->view['filter']['related'] != null))
-				//{
-				//    $this->shop->view['chart']['data'] = $objchartClass->$chartFunction($this->shop->view['standardFilter'][$this->shop->view['filter']['standard']]['point'], array('relatedpoint' => $this->shop->view['standardFilter'][wpsg_getStr($this->shop->view['filter']['related'])]['point'], 'order' => wpsg_getStr($this->shop->view['filter']['order']), 'sort' => wpsg_getStr($this->shop->view['filter']['sort'])));
-				//}
-
-				if (($_REQUEST['page'] == 'wpsg-Statistics') && (wpsg_isSizedString($_REQUEST['id']) != 4))
-				{
-					$this->shop->view['chart']['info'] = $this->shop->view['charts'][$_REQUEST['id']]['type'][$_REQUEST['type']];
-				}
-*/				
+				/*
+					$o = wpsg_getStr($this->shop->view['filter']['order']);
+					$s = wpsg_getStr($this->shop->view['filter']['sort']);
+					$r = wpsg_getStr($this->shop->view['standardFilter'][wpsg_getStr($this->shop->view['filter']['related'])]['point']);
+					$p = $this->shop->view['standardFilter'][$this->shop->view['filter']['standard']]['point'];
+					
+					//$this->shop->view['chart']['data'] = 
+					//$objchartClass->$chartFunction($this->shop->view['standardFilter'][$this->shop->view['filter']['standard']]['point'], 
+					//array('relatedpoint' => $this->shop->view['standardFilter'][wpsg_getStr($this->shop->view['filter']['related'])]['point'], 
+					//      'order' => wpsg_getStr($this->shop->view['filter']['order']), 
+					//      'sort' => wpsg_getStr($this->shop->view['filter']['sort'])));
+					
+					$this->shop->view['chart']['data'] = $objchartClass->$chartFunction($p, array('relatedpoint' => $r, 'order' => $o, 'sort' => $s));
+					
+					//if ((array_key_exists('related', $this->shop->view['filter'])) && ($this->shop->view['filter']['related'] != null))
+					//{
+					//    $this->shop->view['chart']['data'] = $objchartClass->$chartFunction($this->shop->view['standardFilter'][$this->shop->view['filter']['standard']]['point'], array('relatedpoint' => $this->shop->view['standardFilter'][wpsg_getStr($this->shop->view['filter']['related'])]['point'], 'order' => wpsg_getStr($this->shop->view['filter']['order']), 'sort' => wpsg_getStr($this->shop->view['filter']['sort'])));
+					//}
+
+					if (($_REQUEST['page'] == 'wpsg-Statistics') && (wpsg_isSizedString($_REQUEST['id']) != 4))
+					{
+						$this->shop->view['chart']['info'] = $this->shop->view['charts'][$_REQUEST['id']]['type'][$_REQUEST['type']];
+					}
+				*/				
 
 				if (($_REQUEST['page'] == 'wpsg-Statistics'))
@@ -1047,18 +1144,8 @@
 			
 			$this->shop->update_option('wpsg_mod_statistics_google_active', $_REQUEST['wpsg_mod_statistics_google_active'], false, false, WPSG_SANITIZE_CHECKBOX);
-			$this->shop->update_option('wpsg_mod_statistics_google_domainname', $_REQUEST['wpsg_mod_statistics_google_domainname'], false, false, WPSG_SANITIZE_DOMAIN);
 			$this->shop->update_option('wpsg_mod_statistics_google_tracking_code', $_REQUEST['wpsg_mod_statistics_google_tracking_code'], false, false, WPSG_SANITIZE_TEXTFIELD);
-			$this->shop->update_option('wpsg_mod_statistics_google_anonymise_ip_address', $_REQUEST['wpsg_mod_statistics_google_anonymise_ip_address'], false, false, WPSG_SANITIZE_CHECKBOX);
-			$this->shop->update_option('wpsg_mod_statistics_google_opt_out', $_REQUEST['wpsg_mod_statistics_google_opt_out'], false, false, WPSG_SANITIZE_CHECKBOX);
-			$this->shop->update_option('wpsg_mod_statistics_google_enhanced_tracking_code', $_REQUEST['wpsg_mod_statistics_google_enhanced_tracking_code'], false, false, WPSG_SANITIZE_CHECKBOX);
-
-			$this->shop->update_option('wpsg_mod_statistics_google_track_page_load_time', $_REQUEST['wpsg_mod_statistics_google_track_page_load_time'], false, false, WPSG_SANITIZE_CHECKBOX);
-			$this->shop->update_option('wpsg_mod_statistics_google_done', $_REQUEST['wpsg_mod_statistics_google_done'], false, false, WPSG_SANITIZE_TEXTFIELD);
-			$this->shop->update_option('wpsg_mod_statistics_google_basket', $_REQUEST['wpsg_mod_statistics_google_basket'], false, false, WPSG_SANITIZE_TEXTFIELD);
-			$this->shop->update_option('wpsg_mod_statistics_google_checkout', $_REQUEST['wpsg_mod_statistics_google_checkout'], false, false, WPSG_SANITIZE_TEXTFIELD);
-			$this->shop->update_option('wpsg_mod_statistics_google_checkout2', $_REQUEST['wpsg_mod_statistics_google_checkout2'], false, false, WPSG_SANITIZE_TEXTFIELD);
-			$this->shop->update_option('wpsg_mod_statistics_google_overview', $_REQUEST['wpsg_mod_statistics_google_overview'], false, false, WPSG_SANITIZE_TEXTFIELD);
-
-			$this->shop->update_option('wpsg_mod_statistics_socialmedia_fb_px', $_REQUEST['wpsg_mod_statistics_socialmedia_fb_px'], false, false, WPSG_SANITIZE_URL);
+			$this->shop->update_option('wpsg_mod_statistics_google_ecommerce', $_REQUEST['wpsg_mod_statistics_google_ecommerce'], false, false, WPSG_SANITIZE_TEXTFIELD);
+			
+			// $this->shop->update_option('wpsg_mod_statistics_socialmedia_fb_px', $_REQUEST['wpsg_mod_statistics_socialmedia_fb_px'], false, false, WPSG_SANITIZE_URL);
 			
 			$this->shop->update_option('wpsg_mod_statistics_line_chart_width', $_REQUEST['wpsg_mod_statistics_line_chart_width'], false, false, WPSG_SANITIZE_INT, ['allowEmpty' => true]);
@@ -1081,76 +1168,5 @@
 			$this->shop->update_option('wpsg_mod_statistics_googlekey', $_REQUEST['wpsg_mod_statistics_googlekey'], false, false, WPSG_SANITIZE_TEXTFIELD);
 			$this->shop->update_option('wpsg_mod_statistics_productinterval', $_REQUEST['wpsg_mod_statistics_productinterval'], false, false, WPSG_SANITIZE_INT);
-				 
-		}
-		
-		public function get_pagetrackingcode()
-		{
-			
-			if (wpsg_isSizedString($this->simulateUrl))
-			{
-				$requestURI = $this->simulateUrl;
-			}
-			else
-			{
-				$requestURI = $_SERVER['REQUEST_URI'];
-			}
-			
-			//url to track
-	        $pageURL = trim(str_replace(get_site_url().'/', '', $requestURI));
-	        if ($pageURL && preg_match('/^\/.*/i', $pageURL)) {
-	            $pageURL = strval(wpsg_jsquoteescape($pageURL));
-	        }
-
-			$html = '
-            _gaq.push(["_setAccount", "' . wpsg_jsquoteescape($this->shop->get_option('wpsg_mod_statistics_google_tracking_code')) . '"]';
-
-			if ($domainName = $this->shop->get_option('wpsg_mod_statistics_google_domainname')) {
-	            $html .=' ,["_setDomainName","' . $domainName . '"]';
-	        }
-	        if($anonymise = $this->shop->get_option('wpsg_mod_statistics_google_anonymise_ip_address')) {
-	            $html .=', ["_gat._anonymizeIp"]';
-	        }
-	        
-			/*if($this->shop->get_option('wpsg_mod_statistics_google_enable_first_touch_tracking')) {
-	            $html .=');
-	            asyncDistilledFirstTouch(_gaq);
-	            _gaq.push(["_trackPageview","' . $pageURL . '"]';
-	        } else {
-	            $html .=', ["_trackPageview","' . $pageURL . '"]';
-	        }*/
-	        
-			if($this->shop->get_option('wpsg_mod_statistics_google_track_page_load_time')) {
-            	$html .=', ["_trackPageLoadTime"]';
-        	}        
-        	
-        	$html .=');';
-        	
-        	return $html;
-        	
-		}
-		
-		public function get_googleanalytics_html()
-		{
-			
-			$html = '
-<!-- BEGIN_WPSG_GOOGLE_ANALYTICS_CODE -->
-<script type="text/javascript">
-//<![CDATA[
-            (function() {
-            	var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;';
-            
-			$html .= 'ga.src = \'https://google-analytics.com/ga.js\';';
-			
-			$html .= '
-                var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
-            })();
-            var _gaq = _gaq || [];
-'
-			.$this->get_pagetrackingcode().'
-            //]]>
-</script>
-<!-- END_WPSG_GOOGLE_ANALYTICS_CODE -->
-';
-			echo $html;
+		
 		}
 		
@@ -1181,4 +1197,20 @@
 			
 		} // private function usePiwik()
+
+		/**
+		 * Wird irgendeine Google Analytics Konfiguration verwendet
+		 */
+		private function useGA4()
+		{
+			
+			$arConfGA4 = array(
+				'wpsg_mod_statistics_google_ecommerce'
+			);
+			
+			foreach ($arConfGA4 as $c) { if ($this->shop->get_option($c) == '1') { return true; } }
+			
+			return false;
+			
+		} // private function useGA4()
 		
 		/**
@@ -1208,9 +1240,4 @@
 		} // public function loadTopProducts()
 		
-		public function onBasketShow()
-		{
-				
-		}
-		
 		/*
 		 * Abrufen der Statistikdaten im Produktbackend an
Index: /views/mods/mod_statistics/settings_edit.phtml
===================================================================
--- /views/mods/mod_statistics/settings_edit.phtml	(revision 8313)
+++ /views/mods/mod_statistics/settings_edit.phtml	(revision 8314)
@@ -6,5 +6,5 @@
         <li role="presentation"><a href="#tab2" aria-controls="profile" role="tab" data-toggle="tab"><?php echo __('Matomo', 'wpsg'); ?></a></li>
         <li role="presentation"><a href="#tab3" aria-controls="profile" role="tab" data-toggle="tab"><?php echo __('Google', 'wpsg'); ?></a></li>
-        <li role="presentation"><a href="#tab4" aria-controls="profile" role="tab" data-toggle="tab"><?php echo __('Social Media', 'wpsg'); ?></a></li>
+        <!-- <li role="presentation"><a href="#tab4" aria-controls="profile" role="tab" data-toggle="tab"><?php echo __('Social Media', 'wpsg'); ?></a></li> -->
         <li role="presentation"><a href="#tab5" aria-controls="messages" role="tab" data-toggle="tab"><?php echo __('Sonstiges', 'wpsg'); ?></a></li>
     </ul>
@@ -59,5 +59,4 @@
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_generel', __('Allgemeine Protokollierung', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_generel'), array('help' => 'wpsg_mod_statistics_piwik_generel')); ?>
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_ecommerce', __('KÃ€ufe (eCommerce) tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_ecommerce'), array('help' => 'wpsg_mod_statistics_piwik_ecommerce')); ?>
-			<br />
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_productView', __('Produkte tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_productView'), array('help' => 'wpsg_mod_statistics_piwik_productView')); ?>
 			<?php if ($this->hasMod('wpsg_mod_produktartikel')) echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_categoryView', __('Produktkategorien tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_categoryView'), array('help' => 'wpsg_mod_statistics_piwik_categoryView')); ?>
@@ -72,25 +71,25 @@
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_basket', __('Warenkorb tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_basket'), array('help' => 'wpsg_mod_statistics_piwik_basketdata')); ?>
 			<div id="wpsg_mod_statistics_piwik_basket_layer" style="display: none;">
-			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_basket_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_basket_target')); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_basket_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_basket_target')); ?>
 			</div>
 			<br />
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_checkout', __('Checkout tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_checkout')); ?>
 			<div id="wpsg_mod_statistics_piwik_checkout_layer" style="display: none;">
-			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_checkout_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_checkout_target')); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_checkout_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_checkout_target')); ?>
 			</div>
 			<br />
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_checkout2', __('Checkout2 tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_checkout2')); ?>
 			<div id="wpsg_mod_statistics_piwik_checkout2_layer" style="display: none;">
-			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_checkout2_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_checkout2_target')); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_checkout2_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_checkout2_target')); ?>
 			</div>
 			<br />
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_overview', __('Overview tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_overview')); ?>
 			<div id="wpsg_mod_statistics_piwik_overview_layer" style="display: none;">
-			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_overview_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_overview_target')); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_overview_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_overview_target')); ?>
 			</div>
 			<br />
 			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_piwik_done', __('Done tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_done')); ?>
 			<div id="wpsg_mod_statistics_piwik_done_layer" style="display: none;">
-			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_done_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_done_target')); ?>
+				<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_piwik_done_target', __('Matomo ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_piwik_done_target')); ?>
 			</div>
 
@@ -166,77 +165,64 @@
 		
 		<div role="tabpanel" class="tab-pane" id="tab3">
-		<?php 	
-
-			echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_active', __('Google Analytics aktivieren', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_active'), array('help' => 'wpsg_mod_statistics_google_active'));
-			 
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_google_tracking_code', __('Tracking-Code', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_tracking_code'), array('help' => 'wpsg_mod_statistics_google_tracking_code'));
-			
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_google_domainname', __('Domainname', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_domainname'), array('help' => 'wpsg_mod_statistics_google_domainname'));
-			 
-			echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_anonymise_ip_address', __('IP Adresse anonymisieren', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_anonymise_ip_address'), array('help' => 'wpsg_mod_statistics_google_anonymise_ip_address'));
-			 
-			//echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_enable_first_touch_tracking', __('Enable First Touch Tracking', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_enable_first_touch_tracking'));
-			 
-			echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_track_page_load_time', __('Ladegeschwindigkeit der Website erfassen', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_track_page_load_time'), array('help' => 'wpsg_mod_statistics_google_track_page_load_time'));
-
-			echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_opt_out', __('Google Opt Out', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_opt_out'), array('help' => 'wpsg_mod_statistics_google_opt_out'));
-
-			echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_enhanced_tracking_code', __('Enhanced Tacking Code', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_enhanced_tracking_code'), array('help' => 'wpsg_mod_statistics_google_enhanced_tracking_code'));
-		?>
-			<h3><?php echo __('Zieleinrichtung in Google Analytics', 'wpsg'); ?></h3>
-			
-			<?php 
-			echo wpsg_drawForm_Textstart();
-			echo wpsg_drawForm_TextEnd(__('Ziel', 'wpsg'), array('noP' => true));
-			?>
-			
-			<ul>
-				<li>
-		<?php 
-		
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_google_done', __('Bestellabschluss', 'wpsg'), trim(str_replace(get_site_url(), '', $this->getURL(wpsg_ShopController::URL_BASKET).'?wpsg_done')).'=', array('text' => true));
-		
-		?>	
-				</li>
-			</ul>
-			<?php 
-			echo wpsg_drawForm_Textstart();
-			echo wpsg_drawForm_TextEnd(__('Trichter (optional)', 'wpsg'), array('noP' => true));
-			?>
-
-			<ul>
-			
-				<li><?php echo wpsg_drawForm_Input('wpsg_mod_statistics_google_basket', __('Warenkorb', 'wpsg'), trim(str_replace(get_site_url(), '', $this->getURL(wpsg_ShopController::URL_BASKET))), array('text' => true)); ?></li>
-				<li><?php echo wpsg_drawForm_Input('wpsg_mod_statistics_google_checkout', __('Adresse', 'wpsg'), trim(str_replace(get_site_url(), '', $this->getURL(wpsg_ShopController::URL_CHECKOUT))).'=', array('text' => true)); ?></li>
-				<li><?php echo wpsg_drawForm_Input('wpsg_mod_statistics_google_checkout2', __('Versand', 'wpsg'), trim(str_replace(get_site_url(), '', $this->getURL(wpsg_ShopController::URL_CHECKOUT2))).'=', array('text' => true)); ?></li>
-				<li><?php echo wpsg_drawForm_Input('wpsg_mod_statistics_google_overview', __('WarenkorbÃŒbersicht', 'wpsg'), trim(str_replace(get_site_url(), '', $this->getURL(wpsg_ShopController::URL_OVERVIEW))).'=', array('text' => true)); ?></li>
-		
-			</ul>
-		
-			<div class="wpsg_clearer"></div>
-		</div>
-
-		<div role="tabpanel" id="tab4" class="tab-pane">
-		<?php
-			echo wpsg_drawForm_input('wpsg_mod_statistics_socialmedia_fb_px', __('Facebook Pixel', 'wpsg'), $this->get_option('wpsg_mod_statistics_socialmedia_fb_px'), array('help' => 'wpsg_mod_statistics_socialmedia_fb_px'));
-		?>
-			<div class="wpsg_clearer"></div>
-		</div>
+
+			<br/>
+			
+			<?php echo __('ErmÃ¶glicht die Integration von "Google Analytics 4".', 'wpsg'); ?>
+			
+			<br/><br/>
+
+			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_active', __('Trackingcode einbinden', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_active'), array('help' => 'wpsg_mod_statistics_google_active')); ?>
+			<div id="wpsg_mod_statistik_google_tracking_layer" style="display:none;">
+				<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_google_tracking_code', __('Google Tag ID', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_tracking_code'), array('help' => 'wpsg_mod_statistics_google_tracking_code')); ?>
+			</div>
+			<br />
+
+			<?php echo wpsg_drawForm_Checkbox('wpsg_mod_statistics_google_ecommerce', __('KÃ€ufe (eCommerce) tracken', 'wpsg'), $this->get_option('wpsg_mod_statistics_google_ecommerce'), array('help' => 'wpsg_mod_statistics_google_ecommerce')); ?>
+
+			<div class="wpsg_clearer"></div>
+
+		</div>
+		
+		<script>
+
+			document.addEventListener("DOMContentLoaded", function() {
+
+				var GoogleTrackingCheckbox = document.getElementById('wpsg_mod_statistics_google_active');
+				var GoogleTrackingDiv = document.getElementById('wpsg_mod_statistik_google_tracking_layer');
+
+				function toggleGoogleDivVisibility(checkbox, div) 
+				{
+
+					if (checkbox.checked) div.style.display = "block";
+					else div.style.display = "none";
+
+				}
+
+				// Event Listener fÃŒr die Checkboxen
+				GoogleTrackingCheckbox.addEventListener("change", function() {
+				toggleGoogleDivVisibility(GoogleTrackingCheckbox, GoogleTrackingDiv);
+				});
+
+				// ÃberprÃŒfen und Initialisieren des Anfangszustands der Checkboxen
+				toggleGoogleDivVisibility(GoogleTrackingCheckbox, GoogleTrackingDiv);
+
+			});
+
+		</script>
+
+		<!-- <div role="tabpanel" id="tab4" class="tab-pane">
+			<?php // echo wpsg_drawForm_input('wpsg_mod_statistics_socialmedia_fb_px', __('Facebook Pixel', 'wpsg'), $this->get_option('wpsg_mod_statistics_socialmedia_fb_px'), array('help' => 'wpsg_mod_statistics_socialmedia_fb_px')); ?>
+			<div class="wpsg_clearer"></div>
+		</div> -->
 
 		<div role="tabpanel" class="tab-pane" id="tab5">
-		<?php 
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_line_chart_width', __('Liniendiagramm (Breite in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_line_chart_width'), array('help' => 'wpsg_mod_statistics_line_chart_width'));
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_line_chart_height', __('Liniendiagramm (Hoehe in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_line_chart_height'), array('help' => 'wpsg_mod_statistics_line_chart_height'));
-			
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_pie_chart_width', __('Kuchendiagramm (Breite in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_pie_chart_width'), array('help' => 'wpsg_mod_statistics_pie_chart_width'));
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_pie_chart_height', __('Kuchendiagramm (HÃ¶he in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_pie_chart_height'), array('help' => 'wpsg_mod_statistics_pie_chart_height'));
-			
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_bar_chart_width', __('Balkendiagramm (Breite in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_bar_chart_width'), array('help' => 'wpsg_mod_statistics_bar_chart_width'));
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_bar_chart_height', __('Balkendiagramm (HÃ¶he in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_bar_chart_height'), array('help' => 'wpsg_mod_statistics_bar_chart_height'));
-			
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_topproductcount', __('Anzeige Top-Produkte', 'wpsg'), $this->get_option('wpsg_mod_statistics_topproductcount'), array('help' => 'wpsg_mod_statistics_topproductcount'));
-
-			echo wpsg_drawForm_Input('wpsg_mod_statistics_productinterval', __('Intervall-Zeitraum fÃŒr Produktstatistik', 'wpsg'), $this->get_option('wpsg_mod_statistics_productinterval'), array('help' => 'wpsg_mod_statistics_productinterval'));
-		?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_line_chart_width', __('Liniendiagramm (Breite in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_line_chart_width'), array('help' => 'wpsg_mod_statistics_line_chart_width')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_line_chart_height', __('Liniendiagramm (Hoehe in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_line_chart_height'), array('help' => 'wpsg_mod_statistics_line_chart_height')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_pie_chart_width', __('Kuchendiagramm (Breite in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_pie_chart_width'), array('help' => 'wpsg_mod_statistics_pie_chart_width')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_pie_chart_height', __('Kuchendiagramm (HÃ¶he in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_pie_chart_height'), array('help' => 'wpsg_mod_statistics_pie_chart_height')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_bar_chart_width', __('Balkendiagramm (Breite in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_bar_chart_width'), array('help' => 'wpsg_mod_statistics_bar_chart_width')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_bar_chart_height', __('Balkendiagramm (HÃ¶he in px)', 'wpsg'), $this->get_option('wpsg_mod_statistics_bar_chart_height'), array('help' => 'wpsg_mod_statistics_bar_chart_height')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_topproductcount', __('Anzeige Top-Produkte', 'wpsg'), $this->get_option('wpsg_mod_statistics_topproductcount'), array('help' => 'wpsg_mod_statistics_topproductcount')); ?>
+			<?php echo wpsg_drawForm_Input('wpsg_mod_statistics_productinterval', __('Intervall-Zeitraum fÃŒr Produktstatistik', 'wpsg'), $this->get_option('wpsg_mod_statistics_productinterval'), array('help' => 'wpsg_mod_statistics_productinterval')); ?>
 			<div class="wpsg_clearer"></div>
 		</div>
