How do I add a script to the head section of each page?
Permalink 1 user found helpfulI just tried this, but it's not working. This is in my "header.php" under /concrete***/updates/themes/elements:
<?php defined('C5_EXECUTE') or die("Access Denied.");
$this->addHeaderItem('analyticstracking.php');
$this->inc('elements/header_top.php');
$as = new GlobalArea('Header Search');
$blocks = $as->getTotalBlocksInArea();
$displayThirdColumn = $blocks > 0 || $c->isEditMode();
?>
<header>
I've tried modifying each page's "page header" blocks to include this code, but it doesn't work.
<script>
(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),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-xxxxxxxx-x', 'auto');
ga('send', 'pageview');
</script>
http://legacy-documentation.concrete5.org/tutorials/add-tracking-co...
I just figured out that my page themes don't all update with the design function; so, maybe after updating them it'll work (as I mentioned, I have it working on the root dir/home page).
I'll keep you all posted.
By doing this, I am now able to see the granular information (which page a person is viewing).
Another way is if your theme has a header file that is included on every page you could do