Module: Rack::Deduce::Ingest::Helpers

Defined in:
lib/rack/deduce/ingest/helpers.rb

Instance Method Summary collapse

Instance Method Details

#deduce_event_post(event, email, additional = {}, options = {}) ⇒ Object

Sends an event to Deduce

Parameters:

  • event (String)

    The event type

  • email (String)

    The user’s email address

  • additional (Hash) (defaults to: {})
  • options (Hash) (defaults to: {})


33
34
35
36
37
38
39
40
41
# File 'lib/rack/deduce/ingest/helpers.rb', line 33

def deduce_event_post(event, email, additional = {}, options = {})
  additional[:session_id] = session.id unless additional.has_key? :session_id
  additional[:url]        ||= request.original_url
  additional[:user_agent] ||= request.headers['User-Agent']

  html = Rack::Deduce::Ingest.event email, request.remote_ip, event, additional, options
  html = html.html_safe if html.respond_to :html_safe
  html
end

#deduce_ingest_html(email, options = {}) ⇒ Object

Outputs the Deduce ingest Javascript code. A cookie is set indicating the user has been collected from

As this helper outputs HTML tags, when used in Rails it must be marked HTML safe before being written to the page.

Parameters:

  • email (String)

    The user’s email address

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :site_id (String)
  • :ssl (Boolean)


23
24
25
# File 'lib/rack/deduce/ingest/helpers.rb', line 23

def deduce_ingest_html(email, options = {})
  Rack::Deduce::Ingest.html email, options
end