• Product
  • Pricing
  • Docs
  • Using PostHog
  • Community
  • Company
  • Login
  • Docs

  • Overview
    • Quickstart with PostHog Cloud
    • Overview
    • Open-Source
      • Disclaimer
      • Deployment
      • Support
    • Enterprise
      • Overview
      • Support
      • Hosting Costs
        • AWS
        • Azure
        • DigitalOcean
        • Google Cloud Platform
        • EU Hosting Companies
        • Other platforms
      • Instance settings
      • Environment variables
      • Securing PostHog
      • Monitoring with Grafana
      • Running behind a proxy
      • Configuring email
      • Helm chart configuration
      • Deploying ClickHouse using Altinity.Cloud
      • Configuring Slack
      • Overview
        • Overview
        • Upgrade notes
        • Overview
        • 0001-events-sample-by
        • 0002_events_sample_by
        • 0003_fill_person_distinct_id2
        • ClickHouse
          • Backup
          • Debug hanging / freezing process
          • Horizontal scaling (Sharding & replication)
          • Kafka Engine
          • Resize disk
          • Restore
          • Vertical scaling
        • Kafka
          • Resize disk
          • Log retention
        • PostgreSQL
          • Resize disk
          • Troubleshooting long-running migrations
        • Plugin server
          • Overview
          • Ingestion lag
          • Jobs not executing
          • Scheduled tasks not executing
        • MinIO
        • Redis
        • Zookeeper
      • Disaster recovery
    • Troubleshooting and FAQs
    • Overview
    • Ingest live data
    • Ingest historical data
    • Identify users
    • User properties
    • Using a CDP
    • Deploying a reverse proxy
    • Library comparison
    • Badge
    • Browser extensions
      • Snippet installation
      • Android
      • iOS
      • JavaScript
      • Flutter
      • React Native
      • Node.js
      • Go
      • Python
      • Rust
      • Java
      • PHP
      • Ruby
      • Elixir
      • Docusaurus v2
      • Gatsby
      • Google Tag Manager
      • Next.js
      • Nuxt.js
      • Retool
      • RudderStack
      • Segment
      • Sentry
      • Slack
      • Shopify
      • WordPress
      • Message formatting
      • Microsoft Teams
      • Slack
      • Discord
    • Migrate between PostHog instances
    • Migrate from Amplitude
    • Migrate to PostHog Cloud EU
    • To another self-hosted instance
    • Export your events
    • Overview
    • Tutorial
    • Troubleshooting
    • Developer reference
    • Using the PostHog API
    • Jobs
    • Testing
    • TypeScript types
    • Overview
    • POST-only public endpoints
    • Actions
    • Annotations
    • Cohorts
    • Dashboards
    • Event definitions
    • Events
    • Experiments
    • Feature flags
    • Funnels
    • Groups
    • Groups types
    • Insights
    • Invites
    • Members
    • Persons
    • Plugin configs
    • Plugins
    • Projects
    • Property definitions
    • Session recordings
    • Trends
    • Users
    • Data model
    • Overview
    • Data model
    • Ingestion pipeline
    • ClickHouse
    • Querying data
    • Overview
    • GDPR guidance
    • HIPAA guidance
    • CCPA guidance
    • SOC 2
    • Data egress & compliance
    • Data deletion
    • Overview
    • Code of conduct
    • Recognizing contributions
  • Using PostHog

  • Table of contents
      • Dashboards
      • Funnels
      • Group Analytics
      • Insights
      • Lifecycle
      • Path analysis
      • Retention
      • Stickiness
      • Trends
      • Heatmaps
      • Session Recording
      • Correlation Analysis
      • Experimentation
      • Feature Flags
      • Actions
      • Annotations
      • Cohorts
      • Data Management
      • Events
      • Persons
      • Sessions
      • UTM segmentation
      • Team collaboration
      • Organizations & projects
      • Settings
      • SSO & SAML
      • Toolbar
      • Notifications & alerts
    • Overview
      • Amazon Kinesis Import
      • BitBucket Release Tracker
      • Event Replicator
      • GitHub Release Tracker
      • GitHub Star Sync
      • GitLab Release Tracker
      • Heartbeat
      • Ingestion Alert
      • Email Scoring
      • n8n Connector
      • Orbit Connector
      • Redshift Import
      • Rudderstack Import
      • Segment Connector
      • Shopify Connector
      • Stripe Connector
      • Twitter Followers Tracker
      • Zendesk Connector
      • Airbyte Exporter
      • Amazon S3 Export
      • Avo Inspector
      • BigQuery Export
      • Customer.io Connector
      • Databricks Export
      • Engage Connector
      • GCP Pub/Sub Connector
      • Google Cloud Storage Export
      • Hubspot Connector
      • Intercom Connector
      • PagerDuty Connector
      • PostgreSQL Export
      • Redshift Export
      • RudderStack Export
      • Salesforce Connector
      • Sendgrid Connector
      • Sentry Connector
      • Snowflake Export
      • Twilio Connector
      • Variance Connector
      • Pace Integration
      • Zapier Connector
      • Downsampler
      • Event Sequence Timer
      • First Time Event Tracker
      • Property Filter
      • Property Flattener
      • Schema Enforcer
      • Taxonomy Standardizer
      • Unduplicator
      • Advanced GeoIP Enricher
      • Automatic Cohort Creator
      • Currency Normalizer
      • GeoIP Enricher
      • Timestamp Parser
      • URL Normalizer
      • User Agent Populator
      • Pineapple Mode
  • Tutorials
    • Actions
    • Apps
    • Cohorts
    • Configuration
    • Data management
    • Dashboards
    • Experimentation
    • Feature flags
    • Funnels
    • Group analytics
    • Heatmaps
    • Insights
    • Path analysis
    • Retention
    • Session recording
    • Toolbar
    • Trends
  • Support
  • Glossary
  • Docs

  • Overview
    • Quickstart with PostHog Cloud
    • Overview
    • Open-Source
      • Disclaimer
      • Deployment
      • Support
    • Enterprise
      • Overview
      • Support
      • Hosting Costs
        • AWS
        • Azure
        • DigitalOcean
        • Google Cloud Platform
        • EU Hosting Companies
        • Other platforms
      • Instance settings
      • Environment variables
      • Securing PostHog
      • Monitoring with Grafana
      • Running behind a proxy
      • Configuring email
      • Helm chart configuration
      • Deploying ClickHouse using Altinity.Cloud
      • Configuring Slack
      • Overview
        • Overview
        • Upgrade notes
        • Overview
        • 0001-events-sample-by
        • 0002_events_sample_by
        • 0003_fill_person_distinct_id2
        • ClickHouse
          • Backup
          • Debug hanging / freezing process
          • Horizontal scaling (Sharding & replication)
          • Kafka Engine
          • Resize disk
          • Restore
          • Vertical scaling
        • Kafka
          • Resize disk
          • Log retention
        • PostgreSQL
          • Resize disk
          • Troubleshooting long-running migrations
        • Plugin server
          • Overview
          • Ingestion lag
          • Jobs not executing
          • Scheduled tasks not executing
        • MinIO
        • Redis
        • Zookeeper
      • Disaster recovery
    • Troubleshooting and FAQs
    • Overview
    • Ingest live data
    • Ingest historical data
    • Identify users
    • User properties
    • Using a CDP
    • Deploying a reverse proxy
    • Library comparison
    • Badge
    • Browser extensions
      • Snippet installation
      • Android
      • iOS
      • JavaScript
      • Flutter
      • React Native
      • Node.js
      • Go
      • Python
      • Rust
      • Java
      • PHP
      • Ruby
      • Elixir
      • Docusaurus v2
      • Gatsby
      • Google Tag Manager
      • Next.js
      • Nuxt.js
      • Retool
      • RudderStack
      • Segment
      • Sentry
      • Slack
      • Shopify
      • WordPress
      • Message formatting
      • Microsoft Teams
      • Slack
      • Discord
    • Migrate between PostHog instances
    • Migrate from Amplitude
    • Migrate to PostHog Cloud EU
    • To another self-hosted instance
    • Export your events
    • Overview
    • Tutorial
    • Troubleshooting
    • Developer reference
    • Using the PostHog API
    • Jobs
    • Testing
    • TypeScript types
    • Overview
    • POST-only public endpoints
    • Actions
    • Annotations
    • Cohorts
    • Dashboards
    • Event definitions
    • Events
    • Experiments
    • Feature flags
    • Funnels
    • Groups
    • Groups types
    • Insights
    • Invites
    • Members
    • Persons
    • Plugin configs
    • Plugins
    • Projects
    • Property definitions
    • Session recordings
    • Trends
    • Users
    • Data model
    • Overview
    • Data model
    • Ingestion pipeline
    • ClickHouse
    • Querying data
    • Overview
    • GDPR guidance
    • HIPAA guidance
    • CCPA guidance
    • SOC 2
    • Data egress & compliance
    • Data deletion
    • Overview
    • Code of conduct
    • Recognizing contributions
  • Using PostHog

  • Table of contents
      • Dashboards
      • Funnels
      • Group Analytics
      • Insights
      • Lifecycle
      • Path analysis
      • Retention
      • Stickiness
      • Trends
      • Heatmaps
      • Session Recording
      • Correlation Analysis
      • Experimentation
      • Feature Flags
      • Actions
      • Annotations
      • Cohorts
      • Data Management
      • Events
      • Persons
      • Sessions
      • UTM segmentation
      • Team collaboration
      • Organizations & projects
      • Settings
      • SSO & SAML
      • Toolbar
      • Notifications & alerts
    • Overview
      • Amazon Kinesis Import
      • BitBucket Release Tracker
      • Event Replicator
      • GitHub Release Tracker
      • GitHub Star Sync
      • GitLab Release Tracker
      • Heartbeat
      • Ingestion Alert
      • Email Scoring
      • n8n Connector
      • Orbit Connector
      • Redshift Import
      • Rudderstack Import
      • Segment Connector
      • Shopify Connector
      • Stripe Connector
      • Twitter Followers Tracker
      • Zendesk Connector
      • Airbyte Exporter
      • Amazon S3 Export
      • Avo Inspector
      • BigQuery Export
      • Customer.io Connector
      • Databricks Export
      • Engage Connector
      • GCP Pub/Sub Connector
      • Google Cloud Storage Export
      • Hubspot Connector
      • Intercom Connector
      • PagerDuty Connector
      • PostgreSQL Export
      • Redshift Export
      • RudderStack Export
      • Salesforce Connector
      • Sendgrid Connector
      • Sentry Connector
      • Snowflake Export
      • Twilio Connector
      • Variance Connector
      • Pace Integration
      • Zapier Connector
      • Downsampler
      • Event Sequence Timer
      • First Time Event Tracker
      • Property Filter
      • Property Flattener
      • Schema Enforcer
      • Taxonomy Standardizer
      • Unduplicator
      • Advanced GeoIP Enricher
      • Automatic Cohort Creator
      • Currency Normalizer
      • GeoIP Enricher
      • Timestamp Parser
      • URL Normalizer
      • User Agent Populator
      • Pineapple Mode
  • Tutorials
    • Actions
    • Apps
    • Cohorts
    • Configuration
    • Data management
    • Dashboards
    • Experimentation
    • Feature flags
    • Funnels
    • Group analytics
    • Heatmaps
    • Insights
    • Path analysis
    • Retention
    • Session recording
    • Toolbar
    • Trends
  • Support
  • Glossary
  • Docs
  • Integrate PostHog
  • User properties

User properties

Last updated: Dec 20, 2022

On this page

  • Setting properties
  • When to use set and set_once?
  • How are properties managed when merging or aliasing users
  • Person Display Name
  • Default user properties
  • GeoIP Properties

Setting properties

The easiest way to set properties is to add the properties to the identify function during the initial login.

  • Identify the user and set the user properties
JavaScript
posthog.identify('user_id', {
name: 'James PostHog', // also sets the display name in the PostHog UI
email: 'hey@posthog.com',
})
// { name: 'James PostHog', email: 'hey@posthog.com' }

To update the properties of a user you can use set, set_once, and $unset. Depending on the integration library the actual function calls look a bit different, but internally they all work the same way.

  • set: Set the property even if the property exists on the user
JavaScript
posthog.people.set( { location: 'London' })
// { location: 'London' }
  • set_once: Set the property if the property does not exist on the user
JavaScript
posthog.people.set_once( { initial_location: 'Rome'})
posthog.people.set_once( { initial_location: 'London'})
// { initial_location: 'Rome' }

All these methods can be used in properties with normal event capture:

  • Set the properties through a capture
JavaScript
posthog.capture(
'Set some user properties',
{
$set: { location: 'London' },
$set_once: { initial_location: 'London' },
$unset: [ 'priority' ],
}

When to use set and set_once?

Use set when we want the value to be the most recently sent value. For example, to update the email for a user.

Use set_once when we want to set the first value and it to never be updated afterwards, e.g. the first URL that referred a user to the site.

In summary: set always overrides, set_once only writes when the property doesn't already exist on the user.

For example:

JavaScript
posthog.people.set( { location: 'London' })
posthog.people.set( { location: 'Rome' })
// { location: 'Rome' }
posthog.people.set_once( { initial_location: 'London' })
posthog.people.set_once( { initial_location: 'Rome' })
// { location: 'London' }

Note: that we ignore the event timestamps and just process everything at ingestion time.

Sometimes we might want to mix set and set_once usage. Imagine, when we have some heuristics that help us determine a value, but users can also specify it. In these cases it might be beneficial to use set_once for the heuristically computed value and set for user specified value. This way we can ensure that the user specified value is always used, but if the user doesn't specify it, we can still use the heuristically computed value.

How are properties managed when merging or aliasing users

// TODO: Confirm this with Tiina. Is this what this section means: https://posthog.com/docs/integrate/user-properties#how-do-values-get-overridden

When an anonymous user is identified as user (A), all the properties of the anonymous user are added to user (A). If there is a conflict, the properties of user (A) are kept.

JavaScript
client.identify({
distinctId: 'user_A',
properties: {
name: 'User A',
location: 'London',
timezone: 'GMT',
},
})
client.reset()
// as an anonymous user
posthog.people.set({ name: 'Anonymous User', phone: '0800-POSTHOG' })
client.identify({
distinctId: 'user_A',
properties: {
timezone: 'GMT+1', // daylight saving time
},
})
// for user 'user_A', { name: 'User A', location: 'London', phone: '0800-POSTHOG', timezone: 'GMT+1' }

When a user (B) is merged into another user (A), all the properties of the user (B) are added to user (A). If there is a conflict, the properties of user (A) are kept.

JavaScript
client.identify({
distinctId: 'user_A',
properties: {
location: 'London',
name: 'User A',
},
})
client.identify({
distinctId: 'user_B',
properties: {
name: 'User B',
location: 'Rome',
phone: '0800-POSTHOG',
},
})
posthog.alias('user_A', 'user_B')
// for user 'user_A', { name: 'User A', location: 'London', phone: '0800-POSTHOG' }

Any events sent to either user_A or user_B will be received under the same person.

Note: that the '[alias ID]' cannot be associated with multiple distinct ids.

Person Display Name

The person display name is the name that is shown in the PostHog UI. The person properties that are used as the display name can be configured in Project Settings.

Default user properties

It's often useful to set the email property for a user. This is useful for many of the apps, filtering users in the PostHog UI and as the Person Display Name.

The following properties are automatically set for all users when using the posthog-js library:

PropertyProperty NameDescriptionExample
utm_campaignUTM CampaignUTM campaign tag (last-touch).feature launch, discount
utm_contentUTM ContentUTM content tag (last-touch).bottom link, second button
utm_mediumUTM MediumUTM medium tag (last-touch).Social, Organic, Paid, Email
utm_sourceUTM SourceUTM source tag (last-touch).Google, Bing, Twitter, Facebook
$browserBrowserName of the browser the user has used.Chrome, Firefox
$browser_versionBrowser VersionThe version of the browser that was used. Used in combination with Browser.70, 79
$initial_browserInitial BrowserName of the browser the user first used (first-touch).Chrome, Firefox
$initial_browser_versionInitial Browser VersionThe version of the browser that the user first used (first-touch). Used in combination with Browser.70, 79
$initial_current_urlInitial Current URLThe first URL the user visited, including all the trimings.https://example.com/interesting-article?parameter=true
$initial_device_typeInitial Device TypeThe initial type of device that was used (first-touch).Mobile, Tablet, Desktop
$initial_osInitial OSThe operating system that the user first used (first-touch).Windows, Mac OS X
$initial_pathnameInitial Path NameThe path of the Current URL, which means everything in the url after the domain. Data from the first time this user was seen./pricing, /about-us/team
$initial_referrerInitial Referrer URLURL of where the user came from most recently (last-touch). Data from the first time this user was seen.https://google.com/search?q=posthog&rlz=1C...
$initial_referring_domainInitial Referring DomainDomain of where the user came from most recently (last-touch). Data from the first time this user was seen.google.com, facebook.com
$initial_utm_campaignInitial UTM CampaignUTM campaign tag (first-touch).feature launch, discount
$initial_utm_contentInitial UTM ContentUTM content tag (first-touch).bottom link, second button
$initial_utm_mediumInitial UTM MediumUTM medium tag (first-touch).Social, Organic, Paid, Email
$initial_utm_sourceInitial UTM SourceUTM source tag (first-touch).Google, Bing, Twitter, Facebook
$osOSThe operating system of the user.Windows, Mac OS X
$referrerReferrer URLURL of where the user came from most recently (last-touch).https://google.com/search?q=posthog&rlz=1C...
$referring_domainReferring DomainDomain of where the user came from most recently (last-touch).google.com, facebook.com

GeoIP Properties

By default, the GeoIP plugin is turned on which adds the following properties to all events.

PropertyProperty NameDescriptionExample
$geoip_city_nameCity NameName of the city matched to this event's IP address.Sydney, Chennai, Brooklyn
$geoip_continent_codeContinent CodeCode of the continent matched to this event's IP address.OC, AS, NA
$geoip_continent_nameContinent NameName of the continent matched to this event's IP address.Oceania, Asia, North America
$geoip_country_codeCountry CodeCode of the country matched to this event's IP address.AU, IN, US
$geoip_country_nameCountry NameName of the country matched to this event's IP address.Australia, India, United States
$geoip_latitudeLatitudeApproximated latitude matched to this event's IP address.-33.8591, 13.1337, 40.7
$geoip_longitudeLongitudeApproximated longitude matched to this event's IP address.151.2, 80.8008, -73.9
$geoip_postal_codePostal CodeApproximated postal code matched to this event's IP address.2000, 600004, 11211
$geoip_subdivision_1_codeSubdivision 1 CodeCode of the subdivision matched to this event's IP address.NSW, TN, NY
$geoip_subdivision_1_nameSubdivision 1 NameName of the subdivision matched to this event's IP address.New South Wales, Tamil Nadu, New York
$geoip_subdivision_2_codeSubdivision 2 CodeCode of the second subdivision matched to this event's IP address.
$geoip_subdivision_2_nameSubdivision 2 NameName of the second subdivision matched to this event's IP address.
$geoip_time_zoneTimezoneTimezone matched to this event's IP address.Australia/Sydney, Asia/Kolkata, America/New_York
$initial_geoip_city_nameInitial City NameName of the city matched to this event's IP address. Data from the first time this user was seen.Sydney, Chennai, Brooklyn
$initial_geoip_continent_codeInitial Continent CodeCode of the continent matched to this event's IP address. Data from the first time this user was seen.OC, AS, NA
$initial_geoip_continent_nameInitial Continent NameName of the continent matched to this event's IP address. Data from the first time this user was seen.Oceania, Asia, North America
$initial_geoip_country_codeInitial Country CodeCode of the country matched to this event's IP address. Data from the first time this user was seen.AU, IN, US
$initial_geoip_country_nameInitial Country NameName of the country matched to this event's IP address. Data from the first time this user was seen.Australia, India, United States
$initial_geoip_latitudeInitial LatitudeApproximated latitude matched to this event's IP address. Data from the first time this user was seen.-33.8591, 13.1337, 40.7
$initial_geoip_subdivision_1_codeInitial Subdivision 1 CodeCode of the subdivision matched to this event's IP address. Data from the first time this user was seen.NSW, TN, NY
$initial_geoip_longitudeInitial LongitudeApproximated longitude matched to this event's IP address. Data from the first time this user was seen.151.2, 80.8008, -73.9
$initial_geoip_postal_codeInitial Postal CodeApproximated postal code matched to this event's IP address. Data from the first time this user was seen.2000, 600004, 11211
$initial_geoip_subdivision_1_nameInitial Subdivision 1 NameName of the subdivision matched to this event's IP address. Data from the first time this user was seen.New South Wales, Tamil Nadu, New York
$initial_geoip_subdivision_2_codeInitial Subdivision 2 CodeCode of the second subdivision matched to this event's IP address. Data from the first time this user was seen.
$initial_geoip_subdivision_2_nameInitial Subdivision 2 NameName of the second subdivision matched to this event's IP address. Data from the first time this user was seen.
$initial_geoip_time_zoneInitial TimezoneTimezone matched to this event's IP address. Data from the first time this user was seen.Australia/Sydney, Asia/Kolkata, America/New_York

Questions?

Was this page useful?

Next article

Using PostHog with a CDP

What is a CDP? A CDP is a Customer Data Platform. It is a platform that allows you to collect, and send customer data to other tools like product analytics (PostHog!), marketing automation tools, your CRM, data warehouses etc. The most common CDPs are Segment and RudderStack , both of which work with PostHog. If you already have a Customer Data Platforms (CDP) setup or are thinking of using one this guide will help you decide how to integrate with PostHog. Which PostHog CDP setup should I use…

Read next article

Authors

  • Luke Harries
    Luke Harries
  • Tiina Turban
    Tiina Turban
  • Cory Watilo
    Cory Watilo

Share

Jump to:

  • Setting properties
  • When to use set and set_once?
  • How are properties managed when merging or aliasing users
  • Person Display Name
  • Default user properties
  • GeoIP Properties
  • Questions?
  • Product

  • Overview
  • Pricing
  • Product analytics
  • Session recording
  • A/B testing
  • Feature flags
  • Apps
  • Customer stories
  • PostHog vs...
  • Docs

  • Quickstart guide
  • Self-hosting
  • Installing PostHog
  • Building an app
  • API
  • Webhooks
  • How PostHog works
  • Data privacy
  • Using PostHog

  • Product manual
  • Apps manuals
  • Tutorials
  • Community

  • Questions?
  • Product roadmap
  • Contributors
  • Partners
  • Newsletter
  • Merch
  • PostHog FM
  • PostHog on GitHub
  • Handbook

  • Getting started
  • Company
  • Strategy
  • How we work
  • Small teams
  • People & Ops
  • Engineering
  • Product
  • Design
  • Marketing
  • Customer success
  • Company

  • About
  • Team
  • Investors
  • Press
  • Blog
  • FAQ
  • Support
  • Careers
© 2023 PostHog, Inc.
  • Code of conduct
  • Privacy policy
  • Terms