diff --git a/htdocs/header.php b/htdocs/header.php index 3e9641e20793..9a6255ad2e9a 100644 --- a/htdocs/header.php +++ b/htdocs/header.php @@ -60,20 +60,7 @@ */ $icmsTheme = $xoTheme = &$xoopsThemeFactory->createInstance(array('contentTemplate' => @$xoopsOption['template_main'])); $xoopsTpl = $icmsTpl = &$xoTheme->template; -// no longer needed because of ticket #751 -// if ($icmsConfigMetaFooter['use_google_analytics'] === TRUE -// && isset($icmsConfigMetaFooter['google_analytics']) && $icmsConfigMetaFooter['google_analytics'] != '') { -// /* Legacy GA urchin code */ -// //$xoTheme->addScript('http://www.google-analytics.com/urchin.js',array('type' => 'text/javascript'),'_uacct = "UA-' . $icmsConfigMetaFooter['google_analytics'] . '";urchinTracker();'); -// $scheme = parse_url(ICMS_URL, PHP_URL_SCHEME); -// if ($scheme == 'http') { -// /* New GA code, http protocol */ -// $xoTheme->addScript('http://www.google-analytics.com/ga.js', array('type' => 'text/javascript'),''); -// } elseif ($scheme == 'https') { -// /* New GA code, https protocol */ -// $xoTheme->addScript('https://ssl.google-analytics.com/ga.js', array('type' => 'text/javascript'),''); -// } -// } + if (isset($icmsConfigMetaFooter['google_meta']) && $icmsConfigMetaFooter['google_meta'] != '') { $xoTheme->addMeta('meta', 'verify-v1', $icmsConfigMetaFooter['google_meta']); $xoTheme->addMeta('meta', 'google-site-verification', $icmsConfigMetaFooter['google_meta']); diff --git a/htdocs/libraries/icms/view/theme/Object.php b/htdocs/libraries/icms/view/theme/Object.php index e1a4a205f48f..63711a32be96 100644 --- a/htdocs/libraries/icms/view/theme/Object.php +++ b/htdocs/libraries/icms/view/theme/Object.php @@ -210,19 +210,6 @@ public function xoInit($options = array()) { $this->addMeta('meta', substr($name, 5), $value); } elseif (substr($name, 0, 6) == 'footer') { $values = $value; - if ($icmsConfigMetaFooter['use_google_analytics'] == TRUE && isset($icmsConfigMetaFooter['google_analytics']) && $icmsConfigMetaFooter['google_analytics'] != '') { - - $values = $value . ""; - } $this->template->assign("xoops_$name", $values); $this->template->assign("icms_$name", $values); } else { diff --git a/htdocs/plugins/preloads/googleanalytics.php b/htdocs/plugins/preloads/googleanalytics.php new file mode 100644 index 000000000000..ff4afab24043 --- /dev/null +++ b/htdocs/plugins/preloads/googleanalytics.php @@ -0,0 +1,42 @@ +addScript('https://www.googletagmanager.com/gtag/js?id=' . $tagvalue, ['async'=>'async'], '', 'module', 2000); + $xoTheme->addScript('', '', 'window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag(\'js\', new Date()); + + gtag(\'config\', \'' . $tagvalue . '\');', 'module', '2001'); + } else { + echo 'error getting icmsConfigMetaFooter'; + } + } + catch (Exception $e) { + echo $e->getMessage(); + } + } +}