Astro
npm install @flarepanel/astroAdd the component to the <head> of your base layout, so it loads on every page:
---
// src/layouts/Layout.astro
import { OpenPanelComponent } from '@flarepanel/astro';
---
<html lang="en">
<head>
<OpenPanelComponent
clientId="YOUR_CLIENT_ID"
trackScreenViews={true}
trackOutgoingLinks={true}
trackAttributes={true}
/>
</head>
<body>
<slot />
</body>
</html>Track events
Call the helpers from a client-side script:
<button id="signup">Sign up</button>
<script>
import { track } from '@flarepanel/astro';
document.getElementById('signup')?.addEventListener('click', () => {
track('signup_clicked', { location: 'hero' });
});
</script>identify, increment, decrement, screenView, setGlobalProperties and clear work the same way. With trackAttributes, a data-track attribute on any button or link also sends an event, with no script: see Script tag.
Identify a signed-in user
Render the identify component on pages where you know the user:
---
import { IdentifyComponent } from '@flarepanel/astro';
const user = Astro.locals.user;
---
{user && <IdentifyComponent profileId={user.id} email={user.email} />}Self-hosting
Point the component at your own install:
<OpenPanelComponent
clientId="YOUR_CLIENT_ID"
apiUrl="https://api.example.com"
scriptUrl="https://analytics.example.com/op1.js"
/>