Many thanks to Velden and LadyHLG for their suggestions, I have now sorted this using both of their suggestions. All my client needs to do now is add their unique Google Analytics site reference (i.e. UA-XXXXXXX-1): Here's what we have now that works.
Here's the GCB with the smarty call listed first you'll call it with:
Code: Select all
{global_content name='google_analytics_repeat'}
Here's the GCB content
Code: Select all
{$cgsimple->get_page_content('home','Google_Analytics','foo')}
{if !empty($foo)}
{literal}<__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','//www.google-analytics.com/analytics.js','ga');
ga('create', '{/literal}{$foo}', '{$smarty.server.HTTP_HOST}{literal}');
ga('send', 'pageview');
</__script>{/literal}
{/if}
This goes in the head section of your homepage template:
Code: Select all
{content block='Google_Analytics' oneline='true' label='Google Analytics code only - i.e. UA-XXXXXXX-X' assign='Google_Analytics' wysiwyg='false'}
{global_content name='google_analytics_repeat'}
Then on each of the sites other templates, to replicate the script across every page just add:
Code: Select all
{global_content name='google_analytics_repeat'}
This will add/replicate the GA stuff sitewide without your client having to add the GA code on every page themselves.
So you can now let your clients implement their own Google Analytics from the homepage (Content --> Pages --> Home) in their admin section by just adding their UA-XXXXXXX-X reference and it will be distributed sitewide, keeping it simple for them with no script editing, and no need for a GA plugin. Again, thanks to everyone for their input and help.
Going up, woop, woop.