-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 1.4.5 - 1.4 with GA4 fix (#1469)
* Update version.php to 1.4.5 alpha * update files with patch from @skenow
- Loading branch information
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* googleanalytics ga4.php | ||
* Created by david on 13/02/2022 22:41 | ||
* Modified by skenow on 11 June 2024 | ||
*/ | ||
|
||
/** | ||
* preload class to include the Google Analytics V4 tag in the Head of the webpage, after replacing the smarty variable with the GA4 property code | ||
* This can certainly be improved by checking whether we can, based on the preferences by our users (GDPR and cookies) | ||
*/ | ||
class IcmsPreloadGa4 extends IcmsPreloadItem { | ||
|
||
function eventBeforeFooter() { | ||
global $xoopsTpl; | ||
global $icmsTheme; | ||
global $icmsConfigMetaFooter; | ||
global $xoTheme; | ||
|
||
try { | ||
|
||
if ($icmsConfigMetaFooter['use_google_analytics'] == TRUE && isset($icmsConfigMetaFooter['google_analytics']) && $icmsConfigMetaFooter['google_analytics'] != '') { | ||
if (substr($icmsConfigMetaFooter['google_analytics'], 0, 2 ) === "G-") { | ||
$tagvalue = $icmsConfigMetaFooter['google_analytics']; | ||
} else { | ||
$tagvalue = 'UA-' . $icmsConfigMetaFooter['google_analytics']; | ||
} | ||
$xoTheme->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(); | ||
} | ||
} | ||
} | ||
|