A Ruby client of the ConvertLoop REST API. You can sign up for a ConvertLoop account at http://convertloop.co.
1. Install the gem in your Gemfile
gem 'convertloop', '0.1.2'
2. Run bundle install
from the command line.
3. Create a file config/initializers/convertloop.rb
:
ConvertLoop.configure(
:app_id => 'your_app_id',
:api_key => 'your_api_key'
)
1. Install the gem
gem install convertloop
2. Configure the ConvertLoop
object passing your credentials.
require 'convertloop'
ConvertLoop.configure(
:app_id => 'your_app_id',
:api_key => 'your_api_key'
)
You are now ready to start calling the API methods!
You need to pass at least one of the following: pid
, user_id
or email
to identify a user. Use pid
when you are updating a guest of your site (you can obtain this value from the cookie dp_pid
). Use user_id
to match the id
of the user in your application.
ConvertLoop.people.create_or_update(email: "german.escobar@convertloop.co", first_name: "German", last_name: "Escobar", plan: "free")
Any key different to pid
, user_id
, email
, first_seen_at
, last_seen_at
, add_to_segments
, and remove_from_segments
will be treated as a custom attribute of the person.
You can add or remove people from a segment ussing the add_to_segments
and remove_from_segments
keys:
ConvertLoop.people.create_or_update(email: "german.escobar@convertloop.co", add_to_segments: ['Learn Something'], remove_from_segments: ['Lead'])
You can log an event for any person:
ConvertLoop.event_logs.send(name: "Billed", person: { email: "german.escobar@convertloop.co" }, metadata: { credits: 1000 }, ocurred_at: 1.hour.ago)
If you don't specify the ocurred_at
key, the current time will be used. You can use the person
key to add custom attributes to that person, or add or remove that person to/from segments.