mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-22 07:52:29 +03:00
feat: add ga4 property support
Since google analytics is using now GA4 the support for the new script was needed
This commit is contained in:
parent
1700605b7b
commit
acbce19a50
4 changed files with 24 additions and 6 deletions
|
@ -26,8 +26,11 @@ function google_analytics_script()
|
||||||
|
|
||||||
$google_analytics_code = $CI->settings_model->get_setting('google_analytics_code');
|
$google_analytics_code = $CI->settings_model->get_setting('google_analytics_code');
|
||||||
|
|
||||||
if ($google_analytics_code !== '')
|
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 '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
|
||||||
|
@ -39,4 +42,19 @@ function google_analytics_script()
|
||||||
</script>
|
</script>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 '
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id=' . $google_analytics_code . '"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag("js", new Date());
|
||||||
|
gtag("config", "' . $google_analytics_code . '");
|
||||||
|
</script>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ $lang['time_format'] = 'Time Format';
|
||||||
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
|
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
|
||||||
$lang['first_weekday'] = 'First day of week';
|
$lang['first_weekday'] = 'First day of week';
|
||||||
$lang['first_weekday_hint'] = 'Set the first day of the calendar 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['availabilities_type'] = 'Availabilities Type';
|
||||||
$lang['flexible'] = 'Flexible';
|
$lang['flexible'] = 'Flexible';
|
||||||
$lang['fixed'] = 'Fixed';
|
$lang['fixed'] = 'Fixed';
|
||||||
|
|
|
@ -279,7 +279,7 @@ $lang['time_format'] = 'Zeitformat';
|
||||||
$lang['time_format_hint'] = 'Ändern Sie das Zeitanzeigeformat (H - Stunden, M - Minuten).';
|
$lang['time_format_hint'] = 'Ändern Sie das Zeitanzeigeformat (H - Stunden, M - Minuten).';
|
||||||
$lang['first_weekday'] = 'First day of week';
|
$lang['first_weekday'] = 'First day of week';
|
||||||
$lang['first_weekday_hint'] = 'Set the first day of the calendar 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['availabilities_type'] = 'Verfügungstyp';
|
||||||
$lang['flexible'] = 'Flexibel';
|
$lang['flexible'] = 'Flexibel';
|
||||||
$lang['fixed'] = 'Fest';
|
$lang['fixed'] = 'Fest';
|
||||||
|
|
|
@ -149,7 +149,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="google-analytics-code">
|
<label for="google-analytics-code">
|
||||||
Google Analytics ID</label>
|
Google Analytics ID</label>
|
||||||
<input id="google-analytics-code" placeholder="UA-XXXXXXXX-XX"
|
<input id="google-analytics-code" placeholder="UA-XXXXXXXX-XX or G-XXXXXXXXXX"
|
||||||
data-field="google_analytics_code" class="form-control">
|
data-field="google_analytics_code" class="form-control">
|
||||||
<span class="help-block">
|
<span class="help-block">
|
||||||
<?= lang('google_analytics_code_hint') ?>
|
<?= lang('google_analytics_code_hint') ?>
|
||||||
|
|
Loading…
Reference in a new issue