gem install amplitude-api
The following code snippet will immediately track an event to the Amplitude API.
# Configure your Amplitude API key
AmplitudeAPI.api_key = "abcdef123456"
event = AmplitudeAPI::Event.new({
user_id: "123",
event_type: "clicked on home",
time: Time.now,
insert_id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
event_properties: {
cause: "button",
arbitrary: "properties"
}
})
AmplitudeAPI.track(event)
Currently, we are using this in Rails and using ActiveJob to dispatch events asynchronously. I plan on moving background/asynchronous support into this gem.
- Thread support for background dispatching in bulk
- Configurable default account to use when no
user_id
present
I'd love to hear how you're using this. Please check out the issues.