Skip to content

SDKs & Web Components

GrowthOS provides official SDKs and drop-in Web Components so you can integrate tracking, referrals, surveys, and more with minimal effort. Every SDK is open source and wraps the same public APIs you can call directly.

JavaScript SDK

Browser-side tracking and identification. Lightweight, auto-tracks page views and UTM params.

Node.js SDK

Server-side access to the full Management API. Auto-batches ingest events for performance.

Python SDK

Management and Ingest APIs with sync and async clients. Ideal for data pipelines and backend services.

Web Components

Framework-agnostic, embeddable UI components for referrals, surveys, waitlists, and more.


@growthos/js

The browser SDK handles client-side event tracking, user identification, and page view capture. It uses your Write Key and communicates exclusively with the Ingest API.

Terminal window
npm install @growthos/js
import GrowthOS from '@growthos/js';
// Initialize with your Write Key (safe for client-side)
const growthos = GrowthOS.init({
writeKey: 'gos_wk_your_write_key',
autoTrack: {
pageViews: true, // auto-track page views
utmParams: true, // capture UTM parameters from URL
referrer: true, // capture document.referrer
},
});
// Identify a logged-in user
growthos.identify('user_123', {
email: 'jane@acme.com',
name: 'Jane Doe',
plan: 'growth',
signedUpAt: '2025-03-15T10:00:00Z',
});
// Track a custom event
growthos.track('Feature Activated', {
feature: 'referral_program',
source: 'onboarding_checklist',
});
// Manual page view (for SPAs)
growthos.page('Pricing', {
category: 'Marketing',
url: window.location.href,
});
// Associate a user with a company
growthos.group('company_456', {
name: 'Acme Corp',
industry: 'SaaS',
employees: 50,
});
// Alias an anonymous ID to a known user
growthos.alias('user_123', 'anon_abc789');
MethodDescription
growthos.identify(userId, traits)Associate traits with a user. Call on login or profile update.
growthos.track(event, properties)Record a custom event with optional properties.
growthos.page(name, properties)Record a page view. Auto-called if autoTrack.pageViews is enabled.
growthos.group(groupId, traits)Associate the user with a company or organization.
growthos.alias(userId, anonymousId)Link an anonymous visitor to an authenticated user.

The SDK automatically detects route changes in popular frameworks and fires page view events. No additional configuration is required for:

  • React Router (v5 and v6)
  • Next.js (App Router and Pages Router)
  • Vue Router
  • SvelteKit

For custom routers, call growthos.page() manually after each navigation.

The JavaScript SDK respects user privacy by default:

  • Do Not Track — Honors the browser DNT header. When enabled, no events are sent.
  • GDPR Consent Mode — Defer initialization until the user consents:
const growthos = GrowthOS.init({
writeKey: 'gos_wk_your_write_key',
consentMode: 'deferred', // SDK loads but does not send events
});
// After user grants consent:
growthos.grantConsent();

@growthos/node

The server-side SDK gives you full access to both the Ingest API and the Management API. It uses your Secret Key and should only run in trusted server environments.

Terminal window
npm install @growthos/node
import GrowthOS from '@growthos/node';
const growthos = new GrowthOS({
secretKey: process.env.GROWTHOS_SECRET_KEY, // gos_sk_...
// Batching options for ingest calls
batch: {
maxSize: 100, // flush after 100 events
flushInterval: 5000, // or every 5 seconds
},
});

The SDK mirrors the Management API with intuitive resource methods:

// List contacts with filtering
const contacts = await growthos.contacts.list({
filter: { trait: 'plan', operator: 'eq', value: 'growth' },
limit: 50,
});
// Get a single contact
const contact = await growthos.contacts.get('usr_123');
// Create a campaign
const campaign = await growthos.campaigns.create({
name: 'Onboarding Drip — Growth Plan',
type: 'drip',
segment_id: 'seg_growth_users',
steps: [
{ delay: '0h', template_id: 'tpl_welcome' },
{ delay: '24h', template_id: 'tpl_feature_intro' },
{ delay: '72h', template_id: 'tpl_invite_team' },
],
});
// Server-side event tracking (auto-batched)
growthos.track({
userId: 'user_123',
event: 'Subscription Upgraded',
properties: {
previousPlan: 'starter',
newPlan: 'growth',
mrr: 99,
},
});
// Flush pending events before process exit
await growthos.flush();
ResourceMethods
growthos.contactslist(), get(), create(), update(), delete(), merge()
growthos.campaignslist(), get(), create(), update(), activate(), pause()
growthos.segmentslist(), get(), create(), query()
growthos.referralslist(), get(), createProgram(), getStats()
growthos.surveyslist(), get(), create(), getResponses()
growthos.waitlistslist(), get(), create(), approve()
growthos.webhookslist(), create(), delete(), test()

growthos-python

The Python SDK provides the same resource structure as the Node.js SDK, with both synchronous and asynchronous clients.

Terminal window
pip install growthos-python
from growthos import GrowthOS
client = GrowthOS(secret_key="gos_sk_your_secret_key")
# List contacts
contacts = client.contacts.list(limit=25)
# Track an event (auto-batched)
client.track(
user_id="user_123",
event="Subscription Upgraded",
properties={
"previous_plan": "starter",
"new_plan": "growth",
"mrr": 99,
},
)
# Create a referral program
program = client.referrals.create_program(
name="Customer Referral Program",
reward_type="credit",
reward_amount=20,
reward_currency="USD",
)
# Flush before exit
client.flush()
client.close()
from growthos import GrowthOS
async def main():
client = GrowthOS.async_client(secret_key="gos_sk_your_secret_key")
contacts = await client.contacts.list(limit=25)
await client.track(
user_id="user_123",
event="Report Generated",
properties={"report_type": "monthly_growth"},
)
await client.flush()
await client.close()

GrowthOS ships a set of framework-agnostic Web Components that you can drop into any HTML page, React app, Vue project, or static site. They use the Ingest API internally and require only a Write Key.

Add the component library via CDN or npm:

<script
src="https://cdn.growthos.io/components/v1/growthos-components.min.js"
type="module"
></script>

<growthos-referral-widget> — A complete referral UI with share link, copy button, social sharing, and referral stats.

<growthos-referral-widget
write-key="gos_wk_your_write_key"
program-id="prog_001"
user-id="user_123"
theme="light"
></growthos-referral-widget>

Key Attributes:

AttributeTypeDescription
write-keystringYour GrowthOS Write Key
program-idstringReferral program ID
user-idstringCurrent user ID (for personalized link)
themelight or darkColor theme
show-statsbooleanDisplay referral count and reward balance
share-channelsstringComma-separated list: email,twitter,linkedin,copy

Theming via CSS Custom Properties:

growthos-referral-widget {
--gos-primary: #6c5ce7;
--gos-border-radius: 8px;
--gos-font-family: 'Inter', sans-serif;
--gos-bg: #ffffff;
--gos-text: #1a1a2e;
}

Events Emitted:

EventDetail
gos:link-copiedReferral link copied to clipboard
gos:share-clickedSocial share button clicked (includes channel)
gos:referral-stats-loadedStats fetched and rendered

<growthos-survey> — Inline or modal survey and NPS collection.

<growthos-survey
write-key="gos_wk_your_write_key"
survey-id="srv_nps_q1"
user-id="user_123"
display="inline"
></growthos-survey>

Key Attributes:

AttributeTypeDescription
write-keystringYour GrowthOS Write Key
survey-idstringSurvey ID from the dashboard
user-idstringCurrent user ID
displayinline or modalRendering mode
delaynumberMilliseconds before showing (modal mode)
dismiss-on-completebooleanAuto-hide after submission

Theming:

growthos-survey {
--gos-primary: #6c5ce7;
--gos-nps-active: #00b894;
--gos-nps-inactive: #dfe6e9;
--gos-font-family: 'Inter', sans-serif;
}

Events Emitted:

EventDetail
gos:survey-displayedSurvey rendered or modal opened
gos:survey-submittedResponse submitted (includes score and answers)
gos:survey-dismissedUser dismissed the survey

<growthos-waitlist> — Signup form with live position display and referral boost messaging.

<growthos-waitlist
write-key="gos_wk_your_write_key"
waitlist-id="wl_launch_2025"
referral-boost="true"
></growthos-waitlist>

Key Attributes:

AttributeTypeDescription
write-keystringYour GrowthOS Write Key
waitlist-idstringWaitlist ID
referral-boostbooleanShow “share to move up” after signup
show-positionbooleanDisplay current position after signup
fieldsstringComma-separated extra fields: name,company

Events Emitted:

EventDetail
gos:waitlist-joinedUser signed up (includes position)
gos:waitlist-sharedUser shared their referral link

<growthos-social-proof> — Toast notifications showing recent activity (“X people signed up today”).

<growthos-social-proof
write-key="gos_wk_your_write_key"
event-type="waitlist.entry_created"
message-template="\{count\} people joined the waitlist today"
position="bottom-left"
></growthos-social-proof>

Key Attributes:

AttributeTypeDescription
write-keystringYour GrowthOS Write Key
event-typestringEvent to aggregate for count
message-templatestringDisplay message (use count placeholder)
positionstringbottom-left, bottom-right, top-left, top-right
intervalnumberSeconds between toast appearances
show-recent-namesbooleanShow first names of recent signups

Events Emitted:

EventDetail
gos:proof-displayedToast notification shown
gos:proof-clickedUser clicked the notification

<growthos-onboarding> — A step-by-step checklist widget to guide new users through setup.

<growthos-onboarding
write-key="gos_wk_your_write_key"
checklist-id="onb_getting_started"
user-id="user_123"
position="bottom-right"
></growthos-onboarding>

Key Attributes:

AttributeTypeDescription
write-keystringYour GrowthOS Write Key
checklist-idstringChecklist ID from the dashboard
user-idstringCurrent user ID
positionstringWidget position on screen
collapsedbooleanStart in collapsed state

Events Emitted:

EventDetail
gos:step-completedUser completed a checklist step
gos:checklist-completedAll steps completed
gos:checklist-dismissedUser dismissed the checklist

<growthos-nudge> — Contextual banners, modals, and tooltips triggered by user behavior or manual activation.

<growthos-nudge
write-key="gos_wk_your_write_key"
nudge-id="ndg_upgrade_prompt"
user-id="user_123"
type="banner"
position="top"
></growthos-nudge>

Key Attributes:

AttributeTypeDescription
write-keystringYour GrowthOS Write Key
nudge-idstringNudge ID from the dashboard
user-idstringCurrent user ID
typestringbanner, modal, or tooltip
positionstringPlacement: top, bottom, center (varies by type)
triggerstringauto (rule-based), manual, or delay:5000
dismissablebooleanWhether the user can close the nudge

Events Emitted:

EventDetail
gos:nudge-displayedNudge shown to user
gos:nudge-clickedUser clicked the nudge CTA
gos:nudge-dismissedUser dismissed the nudge

While the Web Components work in any framework out of the box, GrowthOS provides thin wrapper packages for better developer experience in popular frameworks.

Terminal window
npm install @growthos/react
import { GrowthOSProvider, useGrowthOS, ReferralWidget } from '@growthos/react';
function App() {
return (
<GrowthOSProvider writeKey="gos_wk_your_write_key">
<Dashboard />
</GrowthOSProvider>
);
}
function Dashboard() {
const { identify, track } = useGrowthOS();
useEffect(() => {
identify('user_123', { email: 'jane@acme.com' });
}, []);
return (
<div>
<ReferralWidget programId="prog_001" userId="user_123" />
<button onClick={() => track('CTA Clicked', { location: 'dashboard' })}>
Invite Friends
</button>
</div>
);
}

The React package provides typed hooks (useGrowthOS, useReferralStats, useSurvey) and component wrappers (ReferralWidget, Survey, Waitlist, etc.) with full TypeScript support.