Ruby Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


LeadTune API Ruby Gem

Copyright 2010 LeadTune, LLC

Eric Wollesen (

For details about the LeadTune API, see:


Authentication credentials can be specified by any of several methods, as detailed below. Available configuration values include:

  • api_key

  • organization

Rack Initializer

# config/initializers/leadtune.rb
Leadtune::Config.api_key = "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
Leadtune::Config.organization = "MYC"

Factors Hash

When initializing your Leadtune::Prospect, you can include your API key and organization along with any factors you wish to submit. These values take precedence over values read from the rack initializer.

Instance Methods

You can also set your API key and organization by calling the Leadtune::Prospect object's #api_key= and #organization= methods. These values take precedence over values read from the factors hash and the rack initializer.

Example Usage

An attempt was made to allow for an ActiveModel-like interface.

require "rubygems"
require "leadtune"

prospect ={
  :api_key => "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f", # required (See Leadtune::Config)
  :organization => "LOL",                 # required (See Leadtune::Config)
  :event => "offers_prepared",            # required
  :email => "",           # required
  :target_buyers => ["TB-LOL", "AcmeU"],  # required
  # ... include optional factors here, see for details

Or alternatively

prospect = do |p|
  p.event = "offers_prepared" = ""
  ... and so on

Or even

prospect =
prospect.event = "offers_prepared" = ""   
... and so on

Automatic Environment Detection

At initialization, an attempt is made to detect your application's current environment. If a rack or rails production environment is detected, prospects will be posted to LeadTune's production host. Otherwise prospects will be posted to LeadTune's sandbox host. The application environment can be overriden via the APP_ENV environment variable, which takes precedence over all other methods.