Pular para o conteúdo

PostHog integration

Este conteúdo ainda não está disponível no seu idioma.

PostHog is a product analytics platform that collects events from your apps and websites. With the Pushwoosh destination in PostHog, the events you already track there reach Pushwoosh as events. Use them to build segments and to start or branch customer journeys.

The destination works only if two fields in its mapping carry Pushwoosh values: the platform field must hold ios, android, or web, and the user field must hold the User ID that Pushwoosh knows the user by. PostHog’s own identifiers don’t match anything in Pushwoosh.

Before you start

Anchor link to

Check that you have the following before you create the destination:

  • The Pushwoosh SDK is integrated in your app.
  • You know which value identifies a user in Pushwoosh. It’s the value your app passes to setUserId, or the device’s Hardware ID (HWID) for users without a custom User ID.
  • PostHog events carry this value. For example, your app calls posthog.identify() with the same ID it passes to setUserId, so the PostHog distinct_id equals the Pushwoosh User ID.
  • You have the application code and an API token from Settings → API Access in Pushwoosh. A Device API token is enough.
  • The token belongs to the account that owns the application.

Create the Pushwoosh destination in PostHog

Anchor link to

Create the destination in PostHog, enter your Pushwoosh credentials, and set the mapping fields.

  1. In PostHog, click New destination.

  2. Search for Pushwoosh and click Create next to it.

    Pushwoosh destination in the PostHog destination catalog
  3. In Pushwoosh API Key, paste the API token.

  4. In Pushwoosh Application Code, paste the application code. It looks like XXXXX-XXXXX.

    Pushwoosh API Key and Pushwoosh Application Code fields in the destination settings
  5. Under Mappings, click Track Events to open its fields.

    Track Events mapping in the destination's Mappings list
  6. Set the fields as described in Map the Track Events fields.

  7. Optionally, click Create Or Update User Profile in the same list and set its fields as described in Map the user profile fields.

  8. Click Create & enable.

Map the Track Events fields

Anchor link to

Three fields decide which user an event belongs to. Fill each of them with a PostHog field that carries the Pushwoosh value, not just any identifier.

External User ID, Device ID, and Device Platform fields in the Track Events mapping
FieldMap it toDon’t map it to
External User IDA field that holds the Pushwoosh User ID or HWID, usually {event.distinct_id}{person.id}, because it’s PostHog’s internal person ID and no Pushwoosh user has it
Device PlatformA field that holds ios, android, or web, usually {event.$os}$device_type, because it holds Mobile or Desktop, not a platform
Device IDA field that holds the Pushwoosh HWID of the device, if your PostHog events carry it. Otherwise clear the fieldPostHog’s own {event.properties.$device_id}, unless your app writes the Pushwoosh HWID into it

External User ID

Anchor link to

Pushwoosh links the event to the user with this ID. distinct_id works only when it equals the Pushwoosh User ID, as described in Before you start.

Device Platform

Anchor link to

Values are case-insensitive, so iOS and Android from $os work as they are.

On websites, $os holds the computer’s operating system, such as Mac OS X. In that case Pushwoosh takes the platform from the $lib event property. Keep Event Properties set to include the entire {event.properties} object so that $lib reaches Pushwoosh.

With the field empty, Pushwoosh records the event for the user as a whole, and it counts for all the user’s devices. A value that isn’t a Pushwoosh HWID matches no device in Pushwoosh.

If the field holds {event.properties.$device_id}, clear it, unless your app writes the Pushwoosh HWID into $device_id.

Other fields

Anchor link to

Leave Name, Timestamp, and Event Properties as PostHog fills them. Each PostHog event becomes a Pushwoosh event with the same name, and Pushwoosh creates missing events and event properties automatically.

Map the user profile fields

Anchor link to

The Create Or Update User Profile mapping sends PostHog person properties to Pushwoosh as tags. It’s optional: set it up if you want to use person properties for targeting and personalization.

  1. Set External User ID the same way as for Track Events.
  2. Leave the device token, device ID, and platform fields empty, unless your PostHog data holds Pushwoosh push tokens.

With only a User ID, Pushwoosh saves the properties as user-specific tags of an existing user and creates no device.

If you map the device token and device ID, map the platform too, to a field that holds ios, android, or web. With any other platform, Pushwoosh rejects the request and saves nothing from it.

Check that the integration works

Anchor link to

Send a test event from the destination, then check a real event in Pushwoosh.

  1. In the destination, click Start testing.
  2. Click Test function to send an example event.
  3. Check that the test shows Success.

Then send a real event for a user who has a device in Pushwoosh. In Pushwoosh, go to Audience → Events, open the event’s three-dot menu, choose Event statistics, and check that the event is counted.

Pushwoosh answers each request with a status and, for rejected events, the reason. The full list of responses is in What Pushwoosh does with data from Segment, as the PostHog destination uses the same endpoints.

Troubleshooting

Anchor link to

If the test or the destination’s logs show an error instead of Success, find the reason below.

The response says token doesn’t match appcode

Anchor link to

The API token belongs to a different account than the application. Create the token in the account that owns the application code.

The response says application not found

Anchor link to

The application code is wrong. Copy it again from the Pushwoosh Control Panel.

The response says invalid argument

Anchor link to

Pushwoosh rejected the event because of its content. The most common cause is that External User ID and Device ID are both empty. Map External User ID to a field that holds the Pushwoosh User ID, as described in Map the Track Events fields. Otherwise, check that the event name and event properties aren’t unusually long.

The test succeeds, but the event isn’t counted for the user

Anchor link to

Check these in order:

  1. The value in External User ID equals the Pushwoosh User ID. With {event.distinct_id}, your app must call posthog.identify() with the same ID it passes to setUserId.
  2. A user with this User ID exists in Pushwoosh. Search for it in Audience → User Explorer.
  3. Device ID is empty or holds a Pushwoosh HWID, not PostHog’s own device ID.