integrations
Tenera Analytics — Advanced Integration
Analytics concepts, browser snippet setup, events, measurement guidance, and product behavior signals.
The one-line snippet handles everything automatically for most use cases. This page explains two additional capabilities: linking anonymous sessions to real users, and enriching a user's persona with extra context.
Identifying users
By default, tpt.js assigns every visitor an anonymous ID stored in their browser (e.g. a3f2b891-…). This is enough for behavioral tracking and clustering, but when you import personas into Tenera you will see unnamed entries.
Call identify once you know who the user is — typically right after sign-in:
window.tenera('identify', 'alice@example.com');
From that point forward, all events from that browser session are tagged with alice@example.com as the user identity. When you click Import Personas, that identifier becomes the persona's name in Tenera.
React example
useEffect(() => {
if (user?.email) {
window.tenera('identify', user.email);
}
}, [user]);
Next.js / App Router example
'use client';
import { useEffect } from 'react';
import { useUser } from '@clerk/nextjs'; // or your auth provider
export function TeneraIdentify() {
const { user } = useUser();
useEffect(() => {
if (user?.primaryEmailAddress?.emailAddress) {
window.tenera('identify', user.primaryEmailAddress.emailAddress);
}
}, [user]);
return null;
}
Organization and project scope (set once)
To enable dashboard filtering by organization/project, set these once in your snippet:
data-project-id(required)data-project-namedata-organization-namedata-organization-domain
Example:
<script src="https://trytenera.ai/tpt.js"
data-write-key="tpt-write-key"
data-project-id="proj_123"
data-project-name="Website"
data-organization-name="Acme"
data-organization-domain="acme.com"
async></script>
These values are attached to tracked events and power organization/project filters in the Tenera Analytics dashboard.
Enriching persona data
Beyond identity, you can attach structured context to a user by tracking a user_profile event with whatever properties are meaningful for your product. These properties are stored alongside the user's behavioral events and imported into Tenera when you click Import Personas — the AI uses them to build a richer, more accurate persona.
window.tenera('track', 'user_profile', {
name: 'Alice Chen',
plan: 'pro',
company: 'Acme Corp',
role: 'engineer',
signedUpAt: '2024-01-15',
usageFrequency: 'daily',
});
Call this once after sign-in, alongside identify. You can call it again any time the user's profile changes (e.g. they upgrade their plan).
Combined example
// After sign-in
window.tenera('identify', user.email);
window.tenera('track', 'user_profile', {
name: user.displayName,
plan: user.subscription.tier,
company: user.organization?.name,
role: user.role,
});
There are no required fields — include whatever context makes sense for how you want to describe your users in AI research sessions.
Custom event tracking
Track product-specific actions that go beyond automatic click and page-view capture:
// Feature usage
window.tenera('track', 'feature_used', {
feature: 'export',
format: 'csv',
});
// Conversion events
window.tenera('track', 'trial_converted', {
plan: 'pro',
billingCycle: 'annual',
});
// Errors or friction points
window.tenera('track', 'checkout_abandoned', {
step: 'payment',
reason: 'card_declined',
});
Custom events feed into the behavioral clustering used to generate persona segments. The more signal you provide, the more meaningful the resulting clusters.
TypeScript types
If you use TypeScript, add a global declaration so window.tenera is typed:
// tenera.d.ts (add anywhere in your project)
interface Window {
tenera: (
command: 'identify' | 'track',
eventOrId: string,
properties?: Record<string, unknown>
) => void;
}