Skip to content

Commit

Permalink
Track tag param
Browse files Browse the repository at this point in the history
  • Loading branch information
katydecorah committed Apr 29, 2024
1 parent eefc85d commit 8d59557
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,31 @@
<script
defer
data-domain="fontlibrary.dev"
src="https://plausible.io/js/script.js"
src="https://plausible.io/js/script.manual.js"
></script>
<script>
window.plausible =
window.plausible ||
function () {
(window.plausible.q = window.plausible.q || []).push(arguments);
};
</script>
<script>
function prepareUrl(params) {
const url = new URL(location.href);
const queryParams = new URLSearchParams(location.search);
let customUrl =
url.protocol + "//" + url.hostname + url.pathname.replace(/\/$/, "");
for (const paramName of params) {
const paramValue = queryParams.get(paramName);
if (paramValue) customUrl = customUrl + "/" + paramValue;
}
return customUrl;
}
plausible("pageview", {
u: prepareUrl(["tag"]) + window.location.search,
});
</script>
{% endif %}
</head>
<body>
Expand Down

0 comments on commit 8d59557

Please sign in to comment.