Skip to content

Commit

Permalink
Add MS Clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
tyom committed Oct 7, 2023
1 parent 8961979 commit 35374c4
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/components/Analytics.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script>
import { browser } from '$app/environment';
import { PUBLIC_GA_MEASUREMENT_ID } from '$env/static/public';
export let id = PUBLIC_GA_MEASUREMENT_ID;
import {
PUBLIC_GA_MEASUREMENT_ID,
PUBLIC_CLARITY_ID,
} from '$env/static/public';
function gtag() {
window.dataLayer.push(arguments);
Expand All @@ -11,10 +12,26 @@
if (browser) {
window.dataLayer = window.dataLayer || [];
gtag('js', new Date());
gtag('config', id);
gtag('config', PUBLIC_GA_MEASUREMENT_ID);
(function (c, l, a, r, i, t, y) {
c[a] =
c[a] ||
function () {
(c[a].q = c[a].q || []).push(arguments);
};
t = l.createElement(r);
t.async = 1;
t.src = `https://www.clarity.ms/tag/${i}`;
y = l.getElementsByTagName(r)[0];
y.parentNode.insertBefore(t, y);
})(window, document, 'clarity', 'script', PUBLIC_CLARITY_ID);
}
</script>

<svelte:head>
<script async src="https://www.googletagmanager.com/gtag/js?id={id}"></script>
<script
async
src="https://www.googletagmanager.com/gtag/js?id={PUBLIC_GA_MEASUREMENT_ID}"
></script>
</svelte:head>

0 comments on commit 35374c4

Please sign in to comment.