Able to Add local analytics.js File into the Theme

This commit is contained in:
Kanti 2014-08-25 14:06:15 +02:00
commit 54f4690dc9

View file

@ -982,14 +982,22 @@ function publisher() {
}
// Google Analytics
function analytics() {
function analytics($analyticsDir = null) {
$analytics = config('google.analytics.id');
if($analyticsDir === null)
{
$analyticsDir = '//www.google-analytics.com/analytics.js';
}
else
{
$analyticsDir = site_url() . 'themes/' . $analyticsDir . 'analytics.js';
}
$script = <<<EOF
<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');
})(window,document,'script','{$analyticsDir}','ga');
ga('create', '{$analytics}', 'auto');
ga('send', 'pageview');