Get PostHog up and running and capture your first event in minutes.
Step 1: Sign up for PostHog Cloud
Create a free PostHog Cloud account:
PostHog Cloud US
Sign up for US Cloud
PostHog Cloud EU
Sign up for EU Cloud
Your first 1 million events, 5,000 recordings, 1 million flag requests, and 100,000 exceptions are free every month.
Step 2: Install PostHog
After signing up, you’ll be prompted to install PostHog. Choose your preferred method:
JavaScript snippet
npm
Python
The quickest way to get started. Add this snippet to your HTML:<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('<ph_project_api_key>', {api_host: 'https://app.posthog.com'})
</script>
Replace <ph_project_api_key> with your project API key from the PostHog dashboard. Install the JavaScript library:Initialize PostHog:import posthog from 'posthog-js'
posthog.init('<ph_project_api_key>', {
api_host: 'https://app.posthog.com'
})
Install the Python library:Initialize and capture events:from posthog import Posthog
posthog = Posthog(
project_api_key='<ph_project_api_key>',
host='https://app.posthog.com'
)
posthog.capture(
distinct_id='user_distinct_id',
event='event_name'
)
Step 3: Capture your first event
Once installed, PostHog automatically captures pageviews and other events. You can also capture custom events:
posthog.capture('button_clicked', {
button_name: 'Sign Up',
location: 'Homepage'
})
Step 4: View your data
After capturing events, view them in PostHog:
- Go to Activity in your PostHog dashboard to see live events
- Create your first Insight to analyze trends
- Set up a Dashboard to monitor key metrics
Next steps
Identify users
Link events to specific users
Create feature flags
Roll out features safely
Set up session replay
Watch user sessions
Explore insights
Analyze user behavior