Skip to content

Commit

Permalink
test GA fake script
Browse files Browse the repository at this point in the history
  • Loading branch information
inanamm committed Aug 8, 2024
1 parent 1c331bf commit b8e3848
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions site/config/config.localhost.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return [
'debug' => true,
'analytics' => false,
'cache' => [
'pages' => [
'type' => 'php',
Expand Down
28 changes: 23 additions & 5 deletions site/snippets/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, shrink-to-fit=no"/>
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, shrink-to-fit=no" />

<?php snippet('seo/head'); ?>
<?php header("Cache-Control: max-age=3600"); ?>
Expand All @@ -14,10 +14,28 @@

<?php snippet('cookieconsentCss') ?>

<?php if ($kirby->option('analytics', false)): ?>
<script id="google-analytics" async type="text/plain" data-category="measurement">
console.log("test");
</script>

<script type="text/plain" data-category="measurement" data-service="Google Analytics">

function setCookie(name, value, days, path) {
let expires = "";
if (days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=" + (path || "/");
}

setCookie("testCookie", "testValue", 7);
setCookie("_ga", "GA1.2.123456789.123456789", 365);
</script>
<?php endif; ?>

<?= vite()->css('index.css') ?>
<?php if ($kirby->option('analytics', false)): ?>
hi boe, analytics are on!
<?php endif; ?>

<?= vite()->css('index.css') ?>
</head>

0 comments on commit b8e3848

Please sign in to comment.