Class: Kameleoon::Conversion

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

Instance Attribute Summary collapse

Attributes inherited from Data

#instance, #sent

Instance Method Summary collapse

Methods inherited from Data

#encode

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.



126
127
128
129
130
131
132
# File 'lib/kameleoon/data.rb', line 126

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

Instance Attribute Details

#goal_idObject

Returns the value of attribute goal_id.



121
122
123
# File 'lib/kameleoon/data.rb', line 121

def goal_id
  @goal_id
end

#negativeObject

Returns the value of attribute negative.



121
122
123
# File 'lib/kameleoon/data.rb', line 121

def negative
  @negative
end

#revenueObject

Returns the value of attribute revenue.



121
122
123
# File 'lib/kameleoon/data.rb', line 121

def revenue
  @revenue
end

Instance Method Details

#obtain_full_post_text_lineObject



134
135
136
137
# File 'lib/kameleoon/data.rb', line 134

def obtain_full_post_text_line
  nonce = Kameleoon::Utils.generate_random_string(NONCE_LENGTH)
  "eventType=conversion&goalId=" + @goal_id.to_s + "&revenue=" + @revenue.to_s + "&negative=" + @negative.to_s + "&nonce=" + nonce
end