Skip to content

Commit

Permalink
chore(analytics): update storybook to use ga4 (#237)
Browse files Browse the repository at this point in the history
Update Storybook analytics to use GA4 and gtag.
  • Loading branch information
williamernest authored May 15, 2023
1 parent a951428 commit e52d73c
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions projects/core/.storybook/manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,26 @@
}
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JKD0PD2LJF"></script>
<script type="text/javascript">
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
function sendPageView() {
gtag('set', 'page', new URLSearchParams(window.location.search).get('path'));
gtag('send', 'pageview');
}

if (/clarity.design/.test(window.location.href)) {
(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', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-86120402-1', 'auto');
gtag('js', new Date());
gtag('config', 'G-JKD0PD2LJF');
sendPageView();

const pushState = window.history.pushState;
window.history.pushState = function () {
pushState.apply(window.history, arguments);
sendPageView();
};

function sendPageView() {
ga('set', 'page', new URLSearchParams(window.location.search).get('path'));
ga('send', 'pageview');
}
}
</script>

0 comments on commit e52d73c

Please sign in to comment.