PostHog कनेक्टर

data-driven marketing campaigns और personalized customer engagement के लिए product analytics data, user behavior events, और cohort memberships sync करने हेतु Tajo के माध्यम से PostHog को Brevo से कनेक्ट करें।

अवलोकन

PropertyValue
PlatformPostHog
CategoryProduct Analytics (Custom)
Setup ComplexityMedium
Official IntegrationNo
Data SyncedEvents, Persons, Feature Flags, Cohorts
Auth MethodPersonal API Key / Project Token

विशेषताएं

  • Event sync - behavioral targeting के लिए PostHog analytics events को Brevo में forward करें
  • Person profile sync - PostHog person properties को Brevo contact attributes से sync करें
  • Cohort-आधारित segmentation - PostHog cohorts को Brevo contact lists से map करें
  • Feature flag sync - enabled feature flags द्वारा contacts segment करें
  • Funnel data - targeted re-engagement के लिए conversion funnel data का उपयोग करें
  • Session replay metadata - session engagement metrics के साथ contacts को समृद्ध करें

पूर्वावश्यकताएं

शुरू करने से पहले, सुनिश्चित करें कि आपके पास हैं:

  1. एक PostHog account (Cloud या self-hosted)
  2. PostHog Settings से एक Personal API Key
  3. Project Settings से आपकी Project API Key (token)
  4. API access वाला एक Brevo account
  5. connector permissions वाला एक Tajo account

प्रमाणीकरण

Personal API Key (Private Endpoints)

Terminal window
# https://app.posthog.com/settings/user-api-keys पर generate करें
export POSTHOG_PERSONAL_API_KEY=phx_your_personal_api_key
export POSTHOG_PROJECT_TOKEN=phc_your_project_token
export POSTHOG_HOST=https://us.posthog.com # or https://eu.posthog.com
export TAJO_API_KEY=your_tajo_api_key
export BREVO_API_KEY=your_brevo_api_key
// Private API endpoints Bearer authentication का उपयोग करते हैं
const headers = {
'Authorization': `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}`,
'Content-Type': 'application/json'
};
// Public endpoints project token का उपयोग करते हैं
const publicHeaders = {
'Content-Type': 'application/json'
};
// Public endpoints के लिए Token request body में pass होता है

API Key Security

Personal API keys पूर्ण account access प्रदान करती हैं। उन्हें कभी भी client-side code में expose न करें। event capture और feature flag evaluation जैसे public endpoints के लिए Project API Key (token) का उपयोग करें।

कॉन्फ़िगरेशन

बेसिक सेटअप

connectors:
posthog:
enabled: true
host: "${POSTHOG_HOST}"
personal_api_key: "${POSTHOG_PERSONAL_API_KEY}"
project_token: "${POSTHOG_PROJECT_TOKEN}"
project_id: "12345"
sync:
persons: true
events: true
cohorts: true
feature_flags: true
schedule: "0 */3 * * *" # हर 3 घंटे में
event_filters:
- "$pageview"
- "purchase_completed"
- "signup_completed"
- "feature_used"
lists:
all_users: 25
active_users: 26
power_users: 27

Field Mapping

field_mapping:
email: email
$name: FIRSTNAME
$browser: BROWSER
$os: OS
$initial_referrer: REFERRAL_SOURCE
total_events: EVENT_COUNT
last_seen: LAST_ACTIVE_DATE
signup_date: SIGNUP_DATE
plan: SUBSCRIPTION_PLAN
company: COMPANY
cohort_names: POSTHOG_COHORTS

API Endpoints

EndpointMethodविवरण
{host}/api/projects/{id}/persons/GETpersons list करें
{host}/api/projects/{id}/events/GETevents list करें
{host}/api/projects/{id}/cohorts/GETcohorts list करें
{host}/api/projects/{id}/feature_flags/GETfeature flags list करें
{host}/api/projects/{id}/feature_flags/evaluation/POSTflags का मूल्यांकन करें
{host}/api/projects/{id}/insights/GETsaved insights list करें
{host}/api/projects/{id}/query/POSTHogQL queries चलाएं
{host}/i/v0/ePOSTevents capture करें (public)
{host}/decide/?v=3POSTFeature flag decisions (public)

कोड उदाहरण

कनेक्टर शुरू करें

import { TajoClient } from '@tajo/sdk';
const tajo = new TajoClient({
apiKey: process.env.TAJO_API_KEY,
brevoApiKey: process.env.BREVO_API_KEY
});
await tajo.connectors.connect('posthog', {
host: process.env.POSTHOG_HOST,
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
projectToken: process.env.POSTHOG_PROJECT_TOKEN,
projectId: '12345'
});

Persons को Brevo से Sync करें

// PostHog persons के माध्यम से paginate करें
let nextUrl = `${posthogHost}/api/projects/${projectId}/persons/?` +
new URLSearchParams({ limit: '100' });
while (nextUrl) {
const response = await fetch(nextUrl, {
headers: {
'Authorization': `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}`
}
});
const data = await response.json();
for (const person of data.results) {
const email = person.properties.$email || person.properties.email;
if (!email) continue;
await tajo.contacts.sync({
email,
attributes: {
FIRSTNAME: person.properties.$name || person.properties.name,
LAST_ACTIVE_DATE: person.properties.$last_seen,
SIGNUP_DATE: person.created_at,
EVENT_COUNT: person.properties.$event_count,
BROWSER: person.properties.$browser,
OS: person.properties.$os,
REFERRAL_SOURCE: person.properties.$initial_referrer
},
listIds: [25]
});
}
nextUrl = data.next;
}

Cohorts को Brevo Lists के रूप में Sync करें

// PostHog cohorts प्राप्त करें और members को Brevo lists से sync करें
const cohortsResponse = await fetch(
`${posthogHost}/api/projects/${projectId}/cohorts/`,
{
headers: {
'Authorization': `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}`
}
}
);
const { results: cohorts } = await cohortsResponse.json();
for (const cohort of cohorts) {
// इस cohort में persons प्राप्त करें
const personsResponse = await fetch(
`${posthogHost}/api/projects/${projectId}/cohorts/${cohort.id}/persons/`,
{
headers: {
'Authorization': `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}`
}
}
);
const { results: persons } = await personsResponse.json();
for (const person of persons) {
const email = person.properties.$email || person.properties.email;
if (email) {
await tajo.contacts.update(email, {
attributes: {
POSTHOG_COHORTS: cohort.name
}
});
}
}
}

Analytics के लिए HogQL Queries चलाएं

// analytics data क्वेरी करने के लिए HogQL का उपयोग करें
const queryResponse = await fetch(
`${posthogHost}/api/projects/${projectId}/query/`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: {
kind: 'HogQLQuery',
query: `
SELECT
properties.$email AS email,
count() AS event_count,
max(timestamp) AS last_event
FROM events
WHERE event = 'purchase_completed'
AND timestamp > now() - interval 30 day
GROUP BY email
HAVING event_count > 3
ORDER BY event_count DESC
LIMIT 1000
`
}
})
}
);
const queryResult = await queryResponse.json();
for (const row of queryResult.results) {
await tajo.contacts.update(row[0], {
attributes: {
PURCHASE_COUNT_30D: row[1],
LAST_PURCHASE: row[2]
}
});
}

Rate Limits

Endpoint CategoryLimitनोट्स
Analytics endpoints240/min, 1,200/hrGET persons, events, insights
Query endpoint2,400/hrHogQL और custom queries
Feature flag evaluation600/minLocal evaluation endpoint
CRUD endpoints480/min, 4,800/hrCreate, update, delete operations
Public endpoints (capture)असीमितEvent capture, flag decisions

Batch Exports

बड़े पैमाने के event data exports के लिए, API के बजाय PostHog के batch exports feature का उपयोग करें। Batch exports S3, BigQuery, Snowflake, और अन्य destinations को support करते हैं।

समस्या निवारण

समस्याकारणसमाधान
401 Unauthorizedअमान्य API keysettings में Personal API Key सत्यापित करें
400 Invalid projectगलत project IDPostHog URL में project ID जांचें
खाली persons listकोई identified users नहींसुनिश्चित करें कि posthog.identify() call हो रहा है
गायब propertiesProperties सेट नहींclient SDK में $set calls सत्यापित करें
Rate limit 429बहुत अधिक requestsbackoff लागू करें, rate limit headers जांचें

Debug Mode

connectors:
posthog:
debug: true
log_level: verbose
log_queries: true
log_sync: true

सर्वोत्तम प्रथाएं

  1. Users को identify करें - person sync enable करने के लिए हमेशा email के साथ posthog.identify() call करें
  2. Segmentation के लिए cohorts का उपयोग करें - Brevo lists के लिए PostHog के behavioral cohorts का लाभ उठाएं
  3. API requests batch करें - बड़े datasets के लिए pagination और batch processing का उपयोग करें
  4. जटिल queries के लिए HogQL का उपयोग करें - SQL जैसी queries के साथ custom analytics extract करें
  5. Batch exports सेट करें - बड़ी data volumes के लिए API polling के बजाय batch exports को प्राथमिकता दें
  6. प्रासंगिक events filter करें - noise कम करने के लिए केवल marketing-relevant events sync करें

सुरक्षा

  • Personal API Key - Scoped Bearer token authentication
  • Project token - केवल client-side operations के लिए public token
  • HTTPS only - सभी endpoints के लिए TLS encryption आवश्यक
  • IP allowlisting - self-hosted instances के लिए उपलब्ध
  • Key scoping - specific permission scopes के साथ API keys बनाएं
  • GitHub secret scanning - PostHog leaked key detection के लिए GitHub के साथ partner करता है

संबंधित संसाधन

Subscribe to updates

developer-docs

Drop your email or phone number — we'll send you what matters next.

auto-detect
AI Assistant

Hi! Ask me anything about the docs.