Home / Integrations / Announcing our PostHog Integration

Announcing our PostHog Integration

Article originally published in May 2024 by Stuart Brameld. Most recent update in June 2024.

Request a demo

Project management for growth and agile marketing professionals. Map your acquisition funnel, integrate analytics and run agile experiments.

Experiment results

Recent experiments results include competitor SEO, AI-driven content, exit-intent modals and AB testing homepage headlines.

Case study

"We are on-track to deliver a 43% increase in inbound leads this year. There is no doubt the adoption of Growth Method is the primary driver behind these results." 

Certified

We are vetted mentors with Growth Mentor and a partner with the Agile Marketing Alliance.

What is PostHog?

PostHog is an open-source product analytics platform that helps companies understand how users interact with their websites or applications. It allows businesses to track user behaviour, analyse data, and gain insights to improve their products or services. PostHog provides features for growth marketers including:

  • Product analytics
  • Web analytics
  • Session replays
  • Feature flags
  • Surveys
  • AB testing

What is Growth Method?

Growth Method is the growth marketing platform for experiment-led and data-driven marketers. Unlike other project management tools like Monday.com and Asana, Growth Method helps marketing teams generate growth, not tasks.

It does this by integrating with core technology in your marketing stack (such as Google Analytics, Salesforce, HubSpot … and now PostHog) enabling you to track and share results right alongside your work.

Integration overview

With Growth Method integrations you can track marketing and sales related metrics right alongside marketing and growth experiments, including:

  • Users and pageviews
  • Marketing data, such as form submissions and conversions
  • Product data, such as new trials
  • Sales data, such as demos and revenue

Integration details

The Growth Method app automatically requests time series data from your connected apps on a daily basis. A standardised set of Growth Method parameters that exist across all vendor integrations as follows:

ParameterSample Value
integrationposthog
propertygrowthmethod.com
metricvisitors
filter (optional)visit:source==Google|Bing|Yandex|DuckDuckGo|Yahoo!
cacheVersion (optional)cacheVersion=2

Data must be received as JSON formatted value, date pairs. This data is cached for 24 hours by default.

[
    {
        "value": 5,
        "date": 20230101
    },
    {
        "value": 21,
        "date": 20230102
    },
    {
        "value": 34,
        "date": 20230103
    },
    {
        "value": 33,
        "date": 20230104
    },
    {
        "value": 32,
        "date": 20230105
    },
    {
        "value": 28,
        "date": 20230106
    }
]

PostHog API

The PostHog API documentation is at https://posthog.com/docs/api.

API rate limits

PostHog rate limits are detailed here https://posthog.com/docs/api#rate-limiting and exist as follows:

  1. The HogQL query endpoint (/api/project/:id/query) has a rate limit of 120 per hour.
  2. For all analytics endpoints (such as calculating insights, retrieving persons, or retrieving session recordings), the rate limits are 240 per minute and 1200 per hour

API authentication

PostHog provide a number of options for authentication using a personal API key, these include:

  1. Using the Authorization header and Bearer authentication (including the key as a bearer token)
  2. Including the key in your request body
  3. Including the key in the query string

To setup authentication you need to:

  1. Go to Account settings and in the ‘Personal API Keys’ section, click “Create a Personal API Key”
  2. Give your key a label – this is just for you, usually to describe the key’s purpose e.g. Growth Method
  3. Choose scopes for your key – our suggested is to use the prebuilt Zapier scope + add Read access to Insights
  4. Choose one of the authentication approaches above – we recommend either Authorization header and Bearer token, or adding your key to the query string
  5. Test access to an API endpoint

Ensure access to specific project This API key will only allow access to selected projects (not all access, or a whole organisation). For more information see https://posthog.com/docs/api.

Time formats

By default PostHog uses UTC for timestamps. To ensure maximum compatibility with PostHog timestamp and sent_at fields should be in ISO-8601 format. ISO 8601 is an internationally agreed way to represent dates: YYYY-MM-DD

2023-12-13T15:45:30.123Z or YYYY-MM-DDTHH:MM:SSZ

Note: the required date format in Growth Method is date YYYYMMDD e.g. 20240413 (not 2024-04-13)

In PostHog, you can override the default date filters with the before and after properties. For example:
“after”: “2024-01-01T00:00:00”,
“before”: “2024-01-01T23:59:59”

API request configuration

  1. Body type: Raw
  2. Content type: JSON (application/json)
  3. Automatically parse responses and convert to JSON/XML

Example Insight query

Insights are the main building blocks of product analytics, and we recommending using the Insights API for Growth Method integration. Using insights ensure data parity between PostHog and Growth Method. The steps are as follows:

  1. Create your insight
  2. Display data for year to date, grouped by date (to meet the daily timeseries data formatting required by Growth Method)
  3. Make an API request as per the Insights API e.g. https://us.posthog.com/project/[Project ID]/insights/[Insight ID]
  4. Parse the resulting data as JSON and format in Make
"result\":[{\"data\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,1,0,0,1,1,0,3,2,1,0,2,2,0,1,3,3,0,2,0,3,0,0,0,2,4,1,0,2,0,1,0,0,2,1,1,1,2,1,0,5,54,1,3,1,0,2,4,3,2,0,0,1,0,1,2,0,5,2,1,2,1,3,5,3,3,6,2,5,5,3,0,3,2,2,4,4,8,2,1,3,4,1,3]

Example HogQL query

Note: The Events endpoint (https://posthog.com/docs/api/events) is deprecated. All integrations should now use the Query endpoint instead https://posthog.com/docs/api/query. You can query events using HogQL (https://posthog.com/docs/product-analytics/sql) via the query endpoint.

Make a POST request to /api/projects/:project_id/query with the required JSON payload, for example:

{"query":{"kind": "HogQLQuery", "query":"SELECT formatDateTime(timestamp,'%Y-%m-%d'), count() FROM events WHERE (event='config_call_booked' OR event='website_call_booked') AND timestamp > '{{20.startDate}}' AND timestamp < '{{20.endDate}}' GROUP BY formatDateTime(timestamp,'%Y-%m-%d') ORDER BY formatDateTime(timestamp,'%Y-%m-%d') DESC"}}

API best practises

  1. Avoid using personal API keys with org-level access
  2. Use a project rather than personal token where possible
  3. Use scoped API keys
  4. If possible, be explicit about the project you want to interact with programmatically

Troubleshooting

PostHog specific

One of the best ways to explore the API is to use PostHog normally, but with the browser network tab open to the Fetch/XHR tab. This gives you an idea of what requests PostHog is sending to generate the data you are seeing. It can be useful if you are trying to recreate a request to see how we do it in PostHog.

Also see https://posthog.com/questions/topic/groups and https://stackoverflow.com/questions/tagged/posthog.

JSON validator

To make sure your JSON is valid, use a JSON validator (for example: https://jsonlint.com/) or use a Create JSON module to create the JSON.

In JSON, data is represented in name/value pairs separated by a comma. The curly bracket contains the object and is separated from the name by a colon. Square brackets hold arrays, and a comma separates the array from values

https://jsonformatter.org

ChatGPT

ChatGPT (use https://chatgpt.com/) is an excellent resources to validate data formats for timeseries data, SQL queries, regular expressions (regex) and more. For example:

I'd like you to check the following SQL query for me:

{"query":{"kind": "HogQLQuery", "query":"SELECT formatDateTime(timestamp,'%Y-%m-%d'), count() FROM events WHERE event='config_call_booked' OR event='website_call_booked' AND timestamp > '{{20.startDate}}' AND timestamp < '{{20.endDate}}' GROUP BY formatDateTime(timestamp,'%Y-%m-%d') ORDER BY formatDateTime(timestamp,'%Y-%m-%d') DESC"}}

ChatGPT responds explainig the issue with the syntax and the correct SQL below

Frequently asked questions

What are webhooks?

Webhooks are often used when multiple applications need to work together. A webhook is a communication mechanism for one application (Application A) to automatically send a message or information to another application (Application B) in response to a specific event.

What is JSON?

JSON is a collection of key value pairs, separated by a comma (,), it doesn’t matter the order these pairs are written in. Individual keys and values are separated by a colon (:) and json always has an opening curly bracket ({) and closing curly bracket (}).

JSON arrays use square opening and closing brackets. Items in arrays are maintained in a collection denoted by curly brackets. Simple arrays have no collections, they are just a comma separated list with no keys. It is also possible to have nested, or multidimensional, arrays.