Astro
For Astro, the CDN script is the simplest integration. Put it once in the shared layout.
Initialize Tracwell
src/layouts/BaseLayout.astro
<head>
<script
is:inline
defer
src="https://collect.tracwell.app/script.js"
data-project-key="tw_live_..."
data-collection-mode="private"
data-consent="granted"
data-respect-do-not-track="true"
></script>
</head>Do not add data-astro-rerun. Full page loads initialize a new document, while Astro client navigation is covered by the SDK's History API listener.
Track an event
Keep the initialized client available to the components or services that own successful product outcomes, then call track() after the outcome completes.
TypeScript
const eventId = analytics.track("signup_completed", {
plan: "starter",
source: "pricing",
});
if (!eventId) {
// Collection is blocked or the event did not pass validation.
}Continue with the custom events guide for naming, property limits, and verification.