A ruby client for the Hubspot HTTP API.
Add this line to your application's Gemfile:
gem 'hubspot-events-ruby', github: 'advocately/hubspot-events-ruby'
And then execute:
$ bundle
Or install it yourself:
$ gem install https://github.com/advocately/hubspot-events-ruby
It's helpful to know that everything below can also be accomplished through the Hubspot JavaScript snippet.
Create an instance of the client with your hubspot organization id. You'll have to ask the support team what your ORG ID is.
hubspot = HubspotEvents::Client.new("YOUR ORG ID")
# Arguments
# attributes (required) - a hash of information about the customer. You can pass any
# information that would be useful in your triggers. You
# must at least pass in an id, email, and created_at timestamp.
hubspot.identify(5, {
email: "bob@example.com",
created_at: customer.created_at.to_i,
first_name: "Bob",
plan: "basic"
})
# Arguments
# user_id (required) - the id of the customer who you want to associate with the event.
# name (required) - the name of the event you want to track.
# attributes (optional) - any related information you'd like to attach to this
# event. These attributes can be used in your triggers to control who should
# receive the triggered email. You can set any number of data values.
hubspot.track(5, "purchase", { type: "socks", price: "13.99" })
Note: If you'd like to track events which occurred in the past, you can include a created_at
attribute
(in seconds since the epoch), and we'll use that as the date the event occurred.
hubspot.track(5, "purchase", type: "socks", price: "13.99", created_at: 1365436200)
- Fork it
- Clone your fork (
git clone git@github.com:MY_USERNAME/hubspot-ruby.git && cd hubspot-ruby
) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request