Class: FacebookAds::ServerSide::AttributionData

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_ads/ad_objects/server_side/attribution_data.rb

Overview

AttributionData indicated the attribution data used for attribution passback event to optimize the performance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope: nil, visit_time: nil, ad_id: nil, adset_id: nil, campaign_id: nil, attribution_share: nil, attribution_model: nil, attr_window: nil, attribution_value: nil, attribution_source: nil, touchpoint_type: nil, touchpoint_ts: nil, attribution_method: nil, decline_reason: nil, auditing_token: nil, linkage_key: nil, attribution_setting: nil) ⇒ AttributionData

Returns a new instance of AttributionData.

Parameters:

  • scope (String) (defaults to: nil)
  • visit_time (Integer) (defaults to: nil)
  • ad_id (String) (defaults to: nil)
  • adset_id (String) (defaults to: nil)
  • campaign_id (String) (defaults to: nil)
  • attribution_share (Float) (defaults to: nil)
  • attribution_model (String) (defaults to: nil)
  • attr_window (String) (defaults to: nil)
  • attribution_value (Float) (defaults to: nil)
  • attribution_source (String) (defaults to: nil)
  • touchpoint_type (String) (defaults to: nil)
  • touchpoint_ts (Integer) (defaults to: nil)
  • attribution_method (String) (defaults to: nil)
  • decline_reason (String) (defaults to: nil)
  • auditing_token (String) (defaults to: nil)
  • linkage_key (String) (defaults to: nil)
  • attribution_setting (FacebookAds::ServerSide::AttributionSetting) (defaults to: nil)


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 97

def initialize(scope: nil, visit_time: nil, ad_id: nil, adset_id: nil, campaign_id: nil, attribution_share: nil, attribution_model: nil, attr_window: nil, attribution_value: nil, attribution_source: nil, touchpoint_type: nil, touchpoint_ts: nil, attribution_method: nil, decline_reason: nil, auditing_token: nil, linkage_key: nil, attribution_setting: nil)
  unless scope.nil?
    self.scope = scope
  end
  unless visit_time.nil?
    self.visit_time = visit_time
  end
  unless ad_id.nil?
    self.ad_id = ad_id
  end
  unless adset_id.nil?
    self.adset_id = adset_id
  end
  unless campaign_id.nil?
    self.campaign_id = campaign_id
  end
  unless attribution_share.nil?
    self.attribution_share = attribution_share
  end
  unless attribution_model.nil?
    self.attribution_model = attribution_model
  end
  unless attr_window.nil?
    self.attr_window = attr_window
  end
  unless attribution_value.nil?
    self.attribution_value = attribution_value
  end
  unless attribution_source.nil?
    self.attribution_source = attribution_source
  end
  unless touchpoint_type.nil?
    self.touchpoint_type = touchpoint_type
  end
  unless touchpoint_ts.nil?
    self.touchpoint_ts = touchpoint_ts
  end
  unless attribution_method.nil?
    self.attribution_method = attribution_method
  end
  unless decline_reason.nil?
    self.decline_reason = decline_reason
  end
  unless auditing_token.nil?
    self.auditing_token = auditing_token
  end
  unless linkage_key.nil?
    self.linkage_key = linkage_key
  end
  unless attribution_setting.nil?
    self.attribution_setting = attribution_setting
  end
end

Instance Attribute Details

#ad_idObject

Meta-provided ad id from URL/deeplink.



34
35
36
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 34

def ad_id
  @ad_id
end

#adset_idObject

Meta-provided adset id from URL/deeplink.



37
38
39
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 37

def adset_id
  @adset_id
end

#attr_windowObject

Attribution woindow in days.



49
50
51
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 49

def attr_window
  @attr_window
end

#attribution_methodObject

The attribution method used to attribute the event.



64
65
66
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 64

def attribution_method
  @attribution_method
end

#attribution_modelObject

Attribution model used to attribute the event.



46
47
48
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 46

def attribution_model
  @attribution_model
end

#attribution_settingObject

The attribution setting for the attribution.



76
77
78
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 76

def attribution_setting
  @attribution_setting
end

#attribution_shareObject

0-1

weight of credit assigned to the visit.



43
44
45
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 43

def attribution_share
  @attribution_share
end

#attribution_sourceObject

The attribution source to differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.



55
56
57
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 55

def attribution_source
  @attribution_source
end

#attribution_valueObject

The share of value generated by this click-conversion pair that is attributed to Meta.



52
53
54
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 52

def attribution_value
  @attribution_value
end

#auditing_tokenObject

The auditing token for the attribution.



70
71
72
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 70

def auditing_token
  @auditing_token
end

#campaign_idObject

Meta-provided campaign id from URL/deeplink.



40
41
42
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 40

def campaign_id
  @campaign_id
end

#decline_reasonObject

The decline reason for the attribution.



67
68
69
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 67

def decline_reason
  @decline_reason
end

#linkage_keyObject

The linkage key for the attribution.



73
74
75
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 73

def linkage_key
  @linkage_key
end

#scopeObject

Touchpoint type.



28
29
30
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 28

def scope
  @scope
end

#touchpoint_tsObject

The time when the touchpoint event occurred with the ad that the install was credited to.



61
62
63
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 61

def touchpoint_ts
  @touchpoint_ts
end

#touchpoint_typeObject

The engagement type that caused the original credited conversion.



58
59
60
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 58

def touchpoint_type
  @touchpoint_type
end

#visit_timeObject

A Unix timestamp in seconds indicating when the campaign_id or fbc was first received.



31
32
33
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 31

def visit_time
  @visit_time
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 229

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      scope == o.scope &&
      visit_time == o.visit_time &&
      ad_id == o.ad_id &&
      adset_id == o.adset_id &&
      campaign_id == o.campaign_id &&
      attribution_share == o.attribution_share &&
      attribution_model == o.attribution_model &&
      attr_window == o.attr_window &&
      attribution_value == o.attribution_value &&
      attribution_source == o.attribution_source &&
      touchpoint_type == o.touchpoint_type &&
      touchpoint_ts == o.touchpoint_ts &&
      attribution_method == o.attribution_method &&
      decline_reason == o.decline_reason &&
      auditing_token == o.auditing_token &&
      linkage_key == o.linkage_key &&
      attribution_setting == o.attribution_setting
end

#build(attributes = {}) ⇒ Object

build the object using the input hash

Parameters:

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

    attributes in the form of hash



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 153

def build(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'scope')
    self.scope = attributes[:'scope']
  end

  if attributes.has_key?(:'visit_time')
    self.visit_time = attributes[:'visit_time']
  end

  if attributes.has_key?(:'ad_id')
    self.ad_id = attributes[:'ad_id']
  end

  if attributes.has_key?(:'adset_id')
    self.adset_id = attributes[:'adset_id']
  end

  if attributes.has_key?(:'campaign_id')
    self.campaign_id = attributes[:'campaign_id']
  end

  if attributes.has_key?(:'attribution_share')
    self.attribution_share = attributes[:'attribution_share']
  end

  if attributes.has_key?(:'attribution_model')
    self.attribution_model = attributes[:'attribution_model']
  end

  if attributes.has_key?(:'attr_window')
    self.attr_window = attributes[:'attr_window']
  end

  if attributes.has_key?(:'attribution_value')
    self.attribution_value = attributes[:'attribution_value']
  end

  if attributes.has_key?(:'attribution_source')
    self.attribution_source = attributes[:'attribution_source']
  end

  if attributes.has_key?(:'touchpoint_type')
    self.touchpoint_type = attributes[:'touchpoint_type']
  end

  if attributes.has_key?(:'touchpoint_ts')
    self.touchpoint_ts = attributes[:'touchpoint_ts']
  end

  if attributes.has_key?(:'attribution_method')
    self.attribution_method = attributes[:'attribution_method']
  end

  if attributes.has_key?(:'decline_reason')
    self.decline_reason = attributes[:'decline_reason']
  end

  if attributes.has_key?(:'auditing_token')
    self.auditing_token = attributes[:'auditing_token']
  end

  if attributes.has_key?(:'linkage_key')
    self.linkage_key = attributes[:'linkage_key']
  end

  if attributes.has_key?(:'attribution_setting')
    self.attribution_setting = attributes[:'attribution_setting']
  end
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • `==` method


252
253
254
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 252

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



258
259
260
261
262
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 258

def hash
  [
    scope, visit_time, ad_id, adset_id, campaign_id, attribution_share, attribution_model, attr_window, attribution_value, attribution_source, touchpoint_type, touchpoint_ts, attribution_method, decline_reason, auditing_token, linkage_key, attribution_setting
  ].hash
end

#normalizeObject

Normalize input fields to server request format.



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 322

def normalize
  hash = {}
  unless scope.nil?
    hash['scope'] = scope
  end
  unless visit_time.nil?
    hash['visit_time'] = visit_time
  end
  unless ad_id.nil?
    hash['ad_id'] = ad_id
  end
  unless adset_id.nil?
    hash['adset_id'] = adset_id
  end
  unless campaign_id.nil?
    hash['campaign_id'] = campaign_id
  end
  unless attribution_share.nil?
    hash['attribution_share'] = attribution_share
  end
  unless attribution_model.nil?
    hash['attribution_model'] = attribution_model
  end
  unless attr_window.nil?
    hash['attr_window'] = attr_window
  end
  unless attribution_value.nil?
    hash['attribution_value'] = attribution_value
  end
  unless attribution_source.nil?
    hash['attribution_source'] = attribution_source
  end
  unless touchpoint_type.nil?
    hash['touchpoint_type'] = touchpoint_type
  end
  unless touchpoint_ts.nil?
    hash['touchpoint_ts'] = touchpoint_ts
  end
  unless attribution_method.nil?
    hash['attribution_method'] = FacebookAds::ServerSide::Util.normalize_attribution_method(attribution_method)
  end
  unless decline_reason.nil?
    hash['decline_reason'] = FacebookAds::ServerSide::Util.normalize_decline_reason(decline_reason)
  end
  unless auditing_token.nil?
    hash['auditing_token'] = auditing_token
  end
  unless linkage_key.nil?
    hash['linkage_key'] = linkage_key
  end
  unless attribution_setting.nil?
    hash['attribution_setting'] = attribution_setting.normalize
  end
  hash
end

#to_sObject



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/facebook_ads/ad_objects/server_side/attribution_data.rb', line 264

def to_s
  hash = {}
  unless scope.nil?
    hash['scope'] = scope
  end
  unless visit_time.nil?
    hash['visit_time'] = visit_time
  end
  unless ad_id.nil?
    hash['ad_id'] = ad_id
  end
  unless adset_id.nil?
    hash['adset_id'] = adset_id
  end
  unless campaign_id.nil?
    hash['campaign_id'] = campaign_id
  end
  unless attribution_share.nil?
    hash['attribution_share'] = attribution_share
  end
  unless attribution_model.nil?
    hash['attribution_model'] = attribution_model
  end
  unless attr_window.nil?
    hash['attr_window'] = attr_window
  end
  unless attribution_value.nil?
    hash['attribution_value'] = attribution_value
  end
  unless attribution_source.nil?
    hash['attribution_source'] = attribution_source
  end
  unless touchpoint_type.nil?
    hash['touchpoint_type'] = touchpoint_type
  end
  unless touchpoint_ts.nil?
    hash['touchpoint_ts'] = touchpoint_ts
  end
  unless attribution_method.nil?
    hash['attribution_method'] = attribution_method
  end
  unless decline_reason.nil?
    hash['decline_reason'] = decline_reason
  end
  unless auditing_token.nil?
    hash['auditing_token'] = auditing_token
  end
  unless linkage_key.nil?
    hash['linkage_key'] = linkage_key
  end
  unless attribution_setting.nil?
    hash['attribution_setting'] = attribution_setting
  end
  hash.to_s
end