# PostHog

## Enable the integration

* Navigate to [our integrations page](https://i.usejimo.com/settings/integrations)
* Click the Connect button of the PostHog integration

<div align="left"><figure><img src="https://i.gyazo.com/f1bb540f65d08f523e217dc01cb5144f.png" alt="" width="375"><figcaption><p>PostHog integration</p></figcaption></figure></div>

## Jimo → PostHog

{% hint style="info" %}
**Requirements**

The Posthog Javascript SDK needs to be injected and used in your application for this to work.
{% endhint %}

Send Jimo events to PostHog. This setup would allow you to capture a comprehensive view of user engagement across your platform. By funneling events from Jimo into PostHog, you can leverage PostHog's powerful analytics tools to track, visualize, and analyze user interactions, helping you to better understand user behavior and refine user experience strategies based on actionable insights. This connection ensures that all relevant user activity within Jimo is seamlessly integrated into PostHog's analytical environment.

<figure><img src="https://i.gyazo.com/811976a55c16613715e7a35024bb4732.png" alt=""><figcaption><p>Visualize and create analytics dashboard based on Jimo events in PostHog</p></figcaption></figure>

You can find a list of possible events and their properties

{% content-ref url="events-for-analytics-integrations" %}
[events-for-analytics-integrations](https://help.usejimo.com/docs/integrations/events-for-analytics-integrations)
{% endcontent-ref %}

#### How to enable?

* Enable the option *Jimo → PostHog* in the integration settings

<figure><img src="https://2794860263-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKzAcDWQbK1gKbpra7bkb%2Fuploads%2FeE5RbmP1309MBV5nLbW5%2Fimage.png?alt=media&#x26;token=ae6caa19-9e97-4326-8f05-fa5dc570b535" alt=""><figcaption><p>Enable Jimo → PostHog</p></figcaption></figure>

{% hint style="success" %}
You are all setup 🎉
{% endhint %}

## PostHog → Jimo

Send PostHog events to Jimo. This setup enables the utilization of PostHog's events within Jimo targeting audiences, specifically for the "Who" section (targeting specific user segments) and creation of Segment of users. This ensures that Jimo's engagements are deeply personalized, enhancing user interaction based on precise analytical insights from PostHog.

<figure><img src="https://i.gyazo.com/164199d1e6b8c27127216a6a35809460.png" alt=""><figcaption><p>Create audience based on PostHog events</p></figcaption></figure>

#### How to enable?

* Enable the option *PostHog → Jimo* in the integration settings

<figure><img src="https://2794860263-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKzAcDWQbK1gKbpra7bkb%2Fuploads%2FK9rUOEwNHk5q2WDroIfI%2Fimage.png?alt=media&#x26;token=bbede2c2-628b-49c3-af42-facd818a2e6a" alt=""><figcaption><p>Enable PostHog → Jimo</p></figcaption></figure>

* Add the following code in your application

```javascript
/**
  Numerous organizations employing PostHog for event tracking generally maintain
  a universally accessible function for capturing these events.
  
  The easiest method to ensure all these events are also recorded in Jimo
  is by integrating a posthog:capture call from the Jimo SDK into this existing function.
  This technique guarantees the simultaneous capture of events across both platforms.
*/

// Create a universal function
const captureEvent = (name, properties) => {
  posthog.capture(name, properties); // You should have this already
  
  window.jimo.push(["do", "posthog:capture", [name, properties]]);
};

// Let's use it
captureEvent("purchase", { amount: 199 })
```

{% hint style="success" %}
You are all setup 🎉
{% endhint %}

## Trigger an experience from a PostHog event

To display an experience following a PostHog event in your application, go to the **Settings** page of the experience, set the trigger to '**On event**,' and select the specific PostHog event to use.

<figure><img src="https://i.gyazo.com/fb7a3ba1a4c94ae5fd86700cdf66af6b.png" alt=""><figcaption><p>Set the experience trigger to <strong>On event</strong></p></figcaption></figure>

<figure><img src="https://i.gyazo.com/cca8b94b3ee2d9ae6bd3cf336f5a12c4.png" alt=""><figcaption><p>Select the PostHog event that should trigger the experience</p></figcaption></figure>
