mirror of
https://github.com/danpros/htmly.git
synced 2026-04-20 12:36:23 +05:30
Able to Add local analytics.js File into the Theme
This commit is contained in:
parent
b769222a3a
commit
54f4690dc9
1 changed files with 10 additions and 2 deletions
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue