Ruby product analytics installation

Add this to your Gemfile:

Terminal
gem "posthog-ruby"

In your app, set your API key before making any calls. If setting a custom host, make sure to include the protocol (e.g. https://).

Ruby
require 'posthog'
posthog = PostHog::Client.new({
api_key: "<ph_project_api_key>",
host: "https://us.i.posthog.com",
on_error: Proc.new { |status, msg| print msg }
})

You can find your project API key and instance address in the project settings page in PostHog.

Community questions

Was this page useful?

Questions about this page? or post a community question.