This template will help you setup custom events for Posthog, allowing you to map event and user parameters for their respective events.
⚠️ This template will only work when Posthog’s snippet is implemented either hardcoded or through a Custom HTML tag as described in Posthog's Google Tag Manager documentation. This is a limitation of the Posthog Javascript SDK.
✅ The benefit of hardcoded or Custom HTML tag approach is that it will allow you to fully configure your Posthog Javascript snippet. Learn more about available configuration options.
- posthog.capture events, including:
- custom event tracking (using dataLayer
event
parameter as event name or any custom value), and the adding of event parameters, and $set and $set_once user parameters. - reset function to reset ids on a logout event
- virtual pageviews for single page application
- custom event tracking (using dataLayer
- posthog.identify events, including:
- user_id
- $set user parameters
- $setOnce user parameters
- posthog.opt_out.tracking and posthog.opt_in_tracking functions that can be used in conjunction with cookie consent triggers
- autoTracking since the Posthog snippet needs to be implemented either hardcoded or through a Custom HTML tag. This option can be disable in the Posthog snippet.
- Implement the Posthog Javascript SDK in Google Tag Manager using a Custom HTML tag with an All Pages trigger (or any trigger that respects your users consent wishes).
- Implement the Posthog Custom Events template for the Google Tag Manager Template Gallery (search for
posthog
). - Create a new tag and select the Posthog Custom Events template.
- Select which type of event you wish to add:
- Custom Event: Choose the source for the even name value, add custom parameters and if applicable set both $set and/or $set_once user parameters defined in the tag.
- Identify: Can only be used when a distinct user ID is available in the dataLayer. Can be expanded with user properties using both $set and $set_once methods.
- Reset: Resets the user’s Posthog cookies and ids. Should be using in conjunction with a log out event.
- User Opt In / Out: Start or stop tracking based on a user’s cookie consent.
- Add all necessary parameters and corresponding dataLayer values.
- Add the trigger and save.
- Super Properties
- Feature Flags
- Alias
- Group Analytics