From acbce19a5061d5e79b5d61f61ff3bc8b1d80dc72 Mon Sep 17 00:00:00 2001 From: David Kagerer Date: Tue, 30 Mar 2021 21:02:53 +0200 Subject: [PATCH] feat: add ga4 property support Since google analytics is using now GA4 the support for the new script was needed --- .../helpers/google_analytics_helper.php | 24 ++++++++++++++++--- .../language/english/translations_lang.php | 2 +- .../language/german/translations_lang.php | 2 +- application/views/backend/settings.php | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/application/helpers/google_analytics_helper.php b/application/helpers/google_analytics_helper.php index 6d26abe1..8229c4eb 100644 --- a/application/helpers/google_analytics_helper.php +++ b/application/helpers/google_analytics_helper.php @@ -26,9 +26,12 @@ function google_analytics_script() $google_analytics_code = $CI->settings_model->get_setting('google_analytics_code'); - if ($google_analytics_code !== '') - { - echo ' + if ($google_analytics_code !== '') { + + // If the google analytics code starts with UA then it is a Universal Analytics Property and the script stays + // the legacy one + if (substr($google_analytics_code, 0, 2) === "UA") { + echo ' '; + } + + // If the google analytics code starts with a G then it is a Google Analytics 4-Property and the script + // to inject it looks different. + if (substr($google_analytics_code, 0, 2) === "G-") { + echo ' + + + '; + } } } diff --git a/application/language/english/translations_lang.php b/application/language/english/translations_lang.php index b5f8df66..3eb2d6d4 100755 --- a/application/language/english/translations_lang.php +++ b/application/language/english/translations_lang.php @@ -282,7 +282,7 @@ $lang['time_format'] = 'Time Format'; $lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).'; $lang['first_weekday'] = 'First day of week'; $lang['first_weekday_hint'] = 'Set the first day of the calendar week.'; -$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.'; +$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page. You can use the tracking id or measurement id.'; $lang['availabilities_type'] = 'Availabilities Type'; $lang['flexible'] = 'Flexible'; $lang['fixed'] = 'Fixed'; diff --git a/application/language/german/translations_lang.php b/application/language/german/translations_lang.php index aecb0ac0..4a20e5ab 100755 --- a/application/language/german/translations_lang.php +++ b/application/language/german/translations_lang.php @@ -279,7 +279,7 @@ $lang['time_format'] = 'Zeitformat'; $lang['time_format_hint'] = 'Ändern Sie das Zeitanzeigeformat (H - Stunden, M - Minuten).'; $lang['first_weekday'] = 'First day of week'; $lang['first_weekday_hint'] = 'Set the first day of the calendar week.'; -$lang['google_analytics_code_hint'] = 'Fügen Sie Ihre Google Analytics-ID hinzu, das auf der Buchungsseite enthalten wird.'; +$lang['google_analytics_code_hint'] = 'Fügen Sie Ihre Google Analytics-ID hinzu, das auf der Buchungsseite enthalten wird. Es kann die Tracking ID oder Mess ID verwendet werden.'; $lang['availabilities_type'] = 'Verfügungstyp'; $lang['flexible'] = 'Flexibel'; $lang['fixed'] = 'Fest'; diff --git a/application/views/backend/settings.php b/application/views/backend/settings.php index 044caaef..f3b758ad 100755 --- a/application/views/backend/settings.php +++ b/application/views/backend/settings.php @@ -149,7 +149,7 @@
-