cal.com
cal.com copied to clipboard
App/Analytics: Posthog Support
Is your proposal related to a problem?
A lot of startups and many other companies use Posthog for analytics and product measurements. It's also open source!
I'd be great to be able to track conversion on booking pages with it.
Describe the solution you'd like
The solution would be something along the lines of:
import posthog from 'posthog-js'
posthog.init([TRACKING-ID], { api_host: [OPTIONAL_HOST]' })
Alternatively:
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init([TRACKING-ID], {api_host: [OPTIONAL_HOST]})
</script>
Note: as Posthog is OSS and also supports custom domains in the hosted version, it's important to allow setting an (optional) host.
If you want to be extra fancy you could also trigger an event when a call is booked:
posthog.capture('calcom_event_booked', {[..optional metadata});
Describe alternatives you've considered
N/A
Additional context
N/A
Requirement/Document
hey @yannleretaille feel free to build this app, you can take inspiration from the fathom and GA4 app
@yannleretaille If GTM app works you can use to track events and call Posthog. I tried use GTM app but nothing happens, its not tracking events from Calcom cloud version.