Track share events

This commit is contained in:
Jade Ellis 2024-08-30 16:05:44 +01:00
parent b7e399b528
commit 3b2e909949
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2

View file

@ -8,6 +8,7 @@
import Toc from "$lib/Toc.svelte";
import type { WithContext, Thing } from "schema-dts";
import pfpUrl from "$lib/logo.svg?url";
import { gtag } from "$lib/analytics.js";
// let GhReleasesDownload: Promise<any>;
// if (data.ghReleaseData) {
// GhReleasesDownload = import("$lib/GhReleasesDownload.svelte").then((m) => m.default)
@ -45,6 +46,14 @@
text: data.post.description,
url: url.href,
});
gtag("event", "share", {
"share_url": url.href,
"share_title": data.post.title,
"share_button": "article_top",
"method": "navigator_share",
"content_type": "article",
});
} catch (error: any) {
if (error.toString().includes("AbortError")) {
return;