Class: Kameleoon::Conversion

Inherits:
Data
  • Object
show all
Defined in:
lib/kameleoon/data/conversion.rb

Overview

Conversion class uses for tracking conversion

Instance Attribute Summary collapse

Attributes inherited from Data

#instance, #sent

Instance Method Summary collapse

Constructor Details

#initialize(goal_id, revenue = 0.0, negative = false) ⇒ Conversion

Returns a new instance of Conversion.

Parameters:

  • goal_id (Integer)

    Id of the goal associated to the conversion

  • revenue (Float) (defaults to: 0.0)

    Optional field - Revenue associated to the conversion.

  • negative (Boolean) (defaults to: false)

    Optional field - If the revenue is negative. By default it’s positive.



15
16
17
18
19
20
# File 'lib/kameleoon/data/conversion.rb', line 15

def initialize(goal_id, revenue = 0.0, negative = false)
  super(DataType::CONVERSION)
  @goal_id = goal_id
  @revenue = revenue || 0.0
  @negative = negative || false
end

Instance Attribute Details

#goal_idObject (readonly)

Returns the value of attribute goal_id.



10
11
12
# File 'lib/kameleoon/data/conversion.rb', line 10

def goal_id
  @goal_id
end

#negativeObject (readonly)

Returns the value of attribute negative.



10
11
12
# File 'lib/kameleoon/data/conversion.rb', line 10

def negative
  @negative
end

#revenueObject (readonly)

Returns the value of attribute revenue.



10
11
12
# File 'lib/kameleoon/data/conversion.rb', line 10

def revenue
  @revenue
end

Instance Method Details

#obtain_full_post_text_lineObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/kameleoon/data/conversion.rb', line 22

def obtain_full_post_text_line
  params = {
    eventType: 'conversion',
    goalId: @goal_id,
    revenue: @revenue,
    negative: @negative,
    nonce: nonce
  }
  Kameleoon::Network::UriHelper.encode_query(params)
end