In order to receive the acurate Google Analytics visitor's data, you want to avoid tracking the access when the site admin visits a concrete5 site.
This is how to hide the Google Analytics tracking code when the users who has the editing permission or admin visited your concrete5 site.
This method only works with concrete5.5.x and later. For concrete5.4.2.2 and earlier, check here
First, create a blank text file /elements/footer_required.php
And paste the following codes
<?php
$_trackingCodePosition = Config::get('SITE_TRACKING_CODE_POSITION');
if (empty($disableTrackingCode) && (empty($_trackingCodePosition) || $_trackingCodePosition === 'bottom')) {
global $cp;
if (is_object($cp) && ($cp->canWrite() || $cp->canAddSubContent() || $cp->canAdminPage())) {
echo '<!-- tracking code disabled -->';
} else {
echo Config::get('SITE_TRACKING_CODE');
}
}
print $this->controller->outputFooterItems();
?>
Copy /concrete/elements/header_required.php onto /elements/header_required.php
Find the following codes (towards the end)
$_trackingCodePosition = Config::get('SITE_TRACKING_CODE_POSITION');
if (empty($disableTrackingCode) && $_trackingCodePosition === 'top') {
echo Config::get('SITE_TRACKING_CODE');
}
onto this
$_trackingCodePosition = Config::get('SITE_TRACKING_CODE_POSITION');
if (empty($disableTrackingCode) && $_trackingCodePosition === 'top') {
if (is_object($cp) && ($cp->canWrite() || $cp->canAddSubContent() || $cp->canAdminPage())) {
echo '<!-- tracking code disabled -->';
} else {
echo Config::get('SITE_TRACKING_CODE');
}
}
Now Google Analytics code will no longer be printed on your concrete5 site when the admin/webmaster visits
Loading Conversation