-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add Basic Visitor Tracking #1462
Add Basic Visitor Tracking #1462
Conversation
I've found a bug in a closure, one moment. |
57df044
to
de958ea
Compare
de958ea
to
3d6d280
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are mainly using the Qwik Framework. We have also enabled react, but we only have one react component on the website.
Qwik might look similar to react with the tsx syntax, but it has another approach than react (resumability vs hydration).
So you need to be aware of....
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: 0 of 1 LGTMs obtained, and all files reviewed, and 2 discussions need to be resolved
web/platform/src/components/qwik/components/visitors.tsx
line 42 at r1 (raw file):
} } ce(`https://sc.lfeeder.com/lftracker_v1_${ss}.js`);
For thirdparty scripts we should use Partytown, since it won't slow down the website performance.
It will use web worker under the hood, so the main thread doesn't get blocked.
For that we don't need a qwik component, since we also use astro as the meta framework for routing.
To integrate partytown in astro you'll need to add the dependency with bun i -D @astrojs/partytown
.
Then you need to import it inthe astro.config.ts
:
...
import tailwindcss from "@tailwindcss/vite";
import partytown from "@astrojs/partytown"; // <--- import the dependency
...
integrations: [
...
partytown() // <-- add the dependency as an integration
],
...
web/platform/src/layouts/Layout.astro
line 26 at r1 (raw file):
<title>{title}</title> <ViewTransitions /> <Visitors />
Let's create a directory for third-party scripts something like src/thirdParty
, and inside you can create alfeeder.astro
file.
An example for google tag manager would be:
---
type Props = { measurementId: string }
const props = Astro.props as Props
const measurementId = props.measurementId
---
<script
type='text/partytown'
src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`}></script>
<script
Then you could include it in the layout.astro
- head like this:
---
import GoogleAnalytics from './GoogleAnalytics.astro'
---
<html lang='en'>
<head>
<meta charset='utf-8' />
<GoogleAnalytics measurementId={'G-XXXXXXXXXX'} />
<title>My page</title>
·
Description
Adds basic visitor tracking. It does lead to a weird server side React warning about
useEffect
that I could use a tip on. I'm not sure if it was there already. First commit to the rewritten website.This change is