forked from mirrors/easyappointments
Merge branch 'add-ga4-support' of https://github.com/c0un7-z3r0/easyappointments into develop
# Conflicts: # application/language/german/translations_lang.php
This commit is contained in:
commit
f9bb741810
3 changed files with 23 additions and 5 deletions
|
@ -26,9 +26,12 @@ 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 !== '') {
|
||||||
{
|
|
||||||
echo '
|
// 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 '
|
||||||
<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(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
@ -38,5 +41,20 @@ function google_analytics_script()
|
||||||
ga("send", "pageview");
|
ga("send", "pageview");
|
||||||
</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>
|
||||||
|
';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,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';
|
||||||
|
|
|
@ -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