Add Trfyx to your Astro project
Astro sites can install Trfyx through a shared layout so the tracker is included across pages.1. Get your Trfyx tracking details
Use the snippet below and replace its Website ID and domain placeholders with the values for your Trfyx project. The tracking script URL ishttps://app.trfyx.com/script.js.
Keep the script URL as https://app.trfyx.com/script.js and replace only the Website ID and domain placeholders with values for your Trfyx project. Do not reuse another project’s identifier.
2. Add the tracker to your shared layout
The recommended approach is to add the tracker to the layout used by your site’s pages. For example, if your project hassrc/layouts/Layout.astro:
Alternative: add it to individual page heads
If your project does not use a shared layout, the Trfyx snippet can be added to each page’s<head>. A shared layout is preferred because it reduces the risk of missing pages or installing the tracker multiple times.
3. Build and deploy
Build your Astro project and deploy it using your normal hosting provider. Check the generated production site rather than relying only on local development when verifying analytics.4. Verify tracking
After deployment:- Open the live website.
- Visit multiple pages.
- Use browser developer tools to confirm the Trfyx script loads successfully.
- Check the Network tab for tracking requests.
- Check your Trfyx dashboard for incoming page activity.
Troubleshooting
If analytics are not appearing:- Confirm every relevant page uses the layout containing the tracker.
- Confirm the exact Trfyx project snippet is being rendered in the final HTML.
- Check for CSP restrictions that could block the script or event requests.
- Confirm the configured domain and project identifier belong to the correct Trfyx project.
- Search the codebase for multiple Trfyx installations and remove duplicates.
- Test the deployed site rather than only localhost.