Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly Inject LDFR Script #1474

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions web/platform/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ export default defineConfig({
}),
starlight(starlightConfig),
sitemap(),
partytown({
config: {
forward: ["dataLayer.push"],
},
}),
partytown(),
],
markdown: {
rehypePlugins: [
Expand Down
82 changes: 61 additions & 21 deletions web/platform/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,72 @@ import "@styles/global.css";
import "@styles/tailwind.css";

import ViewTransitions from "astro/components/ViewTransitions.astro";
import { ScrollTracker } from "@qwik/components/scroll"
import { Header } from "@qwik/components/header"
import { Footer } from "@qwik/components/footer"
import GoogleTagManager from "../thirdParty/GoogleTagManager.astro"
import { ScrollTracker } from "@qwik/components/scroll";
import { Header } from "@qwik/components/header";
import { Footer } from "@qwik/components/footer";
import GoogleTagManager from "../thirdParty/GoogleTagManager.astro";

const { title } = Astro.props;

const scrolled = false;
---

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<GoogleTagManager measurementId={'GTM-NNLLRWGB'} />
<link rel="sitemap" href="/sitemap-index.xml" />
<link rel="icon" sizes="192x192" type="image/png" href="https://nativelink-cdn.s3.us-east-1.amazonaws.com/nativelink_favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<meta name="description" content="NativeLink" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<ViewTransitions />
</head>
<body class="bg-black w-screen">
<ScrollTracker scrolled={scrolled} />
<Header pathName={Astro.url.pathname}/>
<slot />
<Footer />
</body>
<head>
<meta charset="UTF-8" />
<GoogleTagManager measurementId={"GTM-NNLLRWGB"} />
<link rel="sitemap" href="/sitemap-index.xml" />
<link
rel="icon"
sizes="192x192"
type="image/png"
href="https://nativelink-cdn.s3.us-east-1.amazonaws.com/nativelink_favicon.png"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=5.0"
/>
<meta name="description" content="NativeLink" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>

<script>
declare global {
interface Window {
ldfdr?: LdfdrFunction;
}
}
type LdfdrFunction = ((...args: any[]) => void) & { _q?: any[] };
(function (ss: string, ex?: string) {
window.ldfdr =
window.ldfdr ||
function (...args: any[]) {
(window.ldfdr!._q = window.ldfdr!._q || []).push(args);
};
(function (d: Document, s: string) {
const fs = d.getElementsByTagName(s)[0] as HTMLScriptElement;
function ce(src: string) {
const cs = d.createElement(s) as HTMLScriptElement;
cs.src = src;
cs.async = true;
fs.parentNode!.insertBefore(cs, fs);
}
ce(
"https://sc.lfeeder.com/lftracker_v1_" +
ss +
(ex ? "_" + ex : "") +
".js"
);
})(document, "script");
})("lAxoEaKMQGd7OYGd");
</script>
<ViewTransitions />
</head>
<body class="bg-black w-screen">
<ScrollTracker scrolled={scrolled} />
<Header pathName={Astro.url.pathname} />
<slot />
<Footer />
</body>
</html>
3 changes: 2 additions & 1 deletion web/platform/src/thirdParty/GoogleTagManager.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const props = Astro.props as Props
const measurementId = props.measurementId
---
<script
type='text/partytown'
type="text/partytown"
src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`}>
</script>

<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
window.gtag = function gtag(){dataLayer.push(arguments);}
Expand Down