Hide Tracking Code (Google Analytics)
Permalink 2 users found helpful
I've been thinking about hiding Google Analytic code (Tracking Code) when a editable user is browsing around the site.
I wanted to get more accurate access analysis.
So...
I created a blank text file /elements/footer_required.php
Then, insert the following file.
When the user, who can see toolbar, is browsing through a concrete5, the "Tracking Code" won't be printed out to HTML file.
Therefore, access analysis such as Google Analytics won't count your visit.
I wanted to get more accurate access analysis.
So...
I created a blank text file /elements/footer_required.php
Then, insert the following file.
When the user, who can see toolbar, is browsing through a concrete5, the "Tracking Code" won't be printed out to HTML file.
Therefore, access analysis such as Google Analytics won't count your visit.
This was working great for me on v5.4.2.2... but since upgrading my development site to v5.5.1, this breaks the site: the edit bar won't appear at all. I had to remove the custom footer_required.php file altogether in order to get the site edit bar working again.
Anyone have any ideas on how to get this working on C5.5.1?
Thanks!
- John
Anyone have any ideas on how to get this working on C5.5.1?
Thanks!
- John
Here ya go
<?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(); ?>
BTW, this method only works if the tracking code is placed on the footer.
If you are placing the tracking code on header, you need to copy
/concrete/elements/header_required.php
to
/elements/header_required.php
Then find the following codes towards the end of the file
replace it to the following
If you are placing the tracking code on header, you need to copy
/concrete/elements/header_required.php
to
/elements/header_required.php
Then find the following codes towards the end of the file
replace it to the following
$_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'); } }
Thanks a lot, Katz! I am using the Analytics code in the head (it's the asynchronous code), so I'll be sure to use this modification to the header_required.php.
Really appreciate your fast response!
Thanks,
- John
Really appreciate your fast response!
Thanks,
- John
Hi Katz515,
Your post is from a couple of years back, so just wondered if this will work in 5.6.3.2?
Google analytics is showing lots of cID pages and the SEO person on the project is unhappy.
As per other posts: I have deleted all older versions of all of the pages in hopes that that would help as well. And my sitemap has the correct amount of pages in it, pretty URLs are on.
https://www.concrete5.org/community/forums/usage/404-errors-in-my-si...
Thank you for your time.
Cheers
Your post is from a couple of years back, so just wondered if this will work in 5.6.3.2?
Google analytics is showing lots of cID pages and the SEO person on the project is unhappy.
As per other posts: I have deleted all older versions of all of the pages in hopes that that would help as well. And my sitemap has the correct amount of pages in it, pretty URLs are on.
https://www.concrete5.org/community/forums/usage/404-errors-in-my-si...
Thank you for your time.
Cheers
Thanks, this was just what I was looking for.
Been looking for a solution to this so thanks, just to clarify...
I create a new footer_required.php file in /elements (not concrete/elements) and then just add the above code to it.
Is it as easy as that?