* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.1.0
* ---------------------------------------------------------------------------- */
/**
* Print Google Analytics script.
*
* This helper function should be used in view files in order to output the Google Analytics script. It will check
* whether the code is set in the database and print it, otherwise nothing will be outputted. This eliminates the need
* for extra checking before outputting.
*/
function google_analytics_script()
{
$CI =& get_instance();
$CI->load->model('settings_model');
$google_analytics_code = $CI->settings_model->get_setting('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 '
';
}
// 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 '
';
}
}
}