Announcing our PostHog Integration

Article written by
Stuart Brameld
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:
integration: posthog
property: growthmethod.com
metric: visitors
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:
The HogQL query endpoint (/api/project/:id/query) has a rate limit of 120 per hour.
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:
Using the Authorization header and Bearer authentication (including the key as a bearer token)
Including the key in your request body
Including the key in the query string
To setup authentication you need to:
Go to Account settings and in the 'Personal API Keys' section, click "Create a Personal API Key"
Give your key a label – this is just for you, usually to describe the key's purpose e.g. Growth Method
Choose scopes for your key - our suggested is to use the prebuilt Zapier scope + add Read access to Insights
Choose one of the authentication approaches above - we recommend either Authorization header and Bearer token, or adding your key to the query string
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
Body type: Raw
Content type: JSON (application/json)
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:
Create your insight
Display data for year to date, grouped by date (to meet the daily timeseries data formatting required by Growth Method)
Make an API request as per the Insights API e.g. https://us.posthog.com/project/[Project ID]/insights/[Insight ID]
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"}}
Example Trends Query
Trends are a type of insight in posthog, and enable you to track how metrics change over time. You can query trends using the Trends API endpoint (https://posthog.com/docs/api/trend).
Make a GET request to https://us.posthog.com/api/projects/xxxxx/insights/trend/ with the following query string parameters:
Name: actions
Value: {"id":xxxxx}]
Name: filter_test_accounts
Value: 1
Name: date_from
Value: xx-xx-xx
Name: date_to
Value: xx-xx-xx
API best practises
Avoid using personal API keys with org-level access
Use a project rather than personal token where possible
Use scoped API keys
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
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 explaining 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.
Article written by
Stuart Brameld