Class: FacebookAds::ServerSide::UserData
- Inherits:
-
Object
- Object
- FacebookAds::ServerSide::UserData
- Defined in:
- lib/facebook_ads/ad_objects/server_side/user_data.rb
Overview
UserData is a set of identifiers Facebook can use for targeted attribution
Instance Attribute Summary collapse
-
#city ⇒ Object
A city in lower-case without spaces or punctuation.
-
#client_ip_address ⇒ Object
The IP address of the browser corresponding to the event.
-
#client_user_agent ⇒ Object
The user agent for the browser corresponding to the event.
-
#country_code ⇒ Object
A two-letter country code in lowercase.
-
#date_of_birth ⇒ Object
A date of birth given as year, month, and day.
-
#dobd ⇒ Object
The date of birth day.
-
#dobm ⇒ Object
The date of birth month.
-
#doby ⇒ Object
THe date of birth year.
-
#email ⇒ Object
An email address, in lowercase.
-
#external_id ⇒ Object
Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs.
-
#f5first ⇒ Object
The first 5 letters of the first name.
-
#f5last ⇒ Object
The first 5 letters of the last name.
-
#fbc ⇒ Object
The Facebook click ID value stored in the _fbc browser cookie under your domain.
-
#fbp ⇒ Object
The Facebook browser ID value stored in the _fbp browser cookie under your domain.
-
#fi ⇒ Object
The first initial.
-
#first_name ⇒ Object
A first name in lowercase.
-
#gender ⇒ Object
Gender, in lowercase.
-
#last_name ⇒ Object
A last name in lowercase.
-
#lead_id ⇒ Object
The lead ID for the user in this transaction.
-
#phone ⇒ Object
A phone number.
-
#state ⇒ Object
A two-letter state code in lowercase.
-
#subscription_id ⇒ Object
The subscription ID for the user in this transaction.
-
#zip_code ⇒ Object
A five-digit zip code for United States.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#build(attributes = {}) ⇒ Object
build the object using the input hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(email: nil, phone: nil, gender: nil, date_of_birth: nil, last_name: nil, first_name: nil, city: nil, state: nil, country_code: nil, zip_code: nil, external_id: nil, client_ip_address: nil, client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil, lead_id: nil, f5first: nil, f5last: nil, fi: nil, dobd: nil, dobm: nil, doby: nil) ⇒ UserData
constructor
UserData is a set of identifiers Facebook can use for targeted attribution.
-
#normalize ⇒ Object
Normalize input fields to server request format.
-
#to_s ⇒ String
Returns the string representation of the object.
Constructor Details
#initialize(email: nil, phone: nil, gender: nil, date_of_birth: nil, last_name: nil, first_name: nil, city: nil, state: nil, country_code: nil, zip_code: nil, external_id: nil, client_ip_address: nil, client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil, lead_id: nil, f5first: nil, f5last: nil, fi: nil, dobd: nil, dobm: nil, doby: nil) ⇒ UserData
UserData is a set of identifiers Facebook can use for targeted attribution
139 140 141 142 143 144 145 146 147 148 149 150 151 152 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 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 139 def initialize(email: nil, phone: nil, gender: nil, date_of_birth: nil, last_name: nil, first_name: nil, city: nil, state: nil, country_code: nil, zip_code: nil, external_id: nil, client_ip_address: nil, client_user_agent: nil, fbc: nil, fbp: nil, subscription_id: nil, lead_id: nil, f5first: nil, f5last: nil, fi: nil, dobd: nil, dobm: nil, doby: nil) unless email.nil? self.email = email end unless phone.nil? self.phone = phone end unless gender.nil? self.gender = gender end unless date_of_birth.nil? self.date_of_birth = date_of_birth end unless last_name.nil? self.last_name = last_name end unless first_name.nil? self.first_name = first_name end unless city.nil? self.city = city end unless state.nil? self.state = state end unless country_code.nil? self.country_code = country_code end unless zip_code.nil? self.zip_code = zip_code end unless external_id.nil? self.external_id = external_id end unless client_ip_address.nil? self.client_ip_address = client_ip_address end unless client_user_agent.nil? self.client_user_agent = client_user_agent end unless fbc.nil? self.fbc = fbc end unless fbp.nil? self.fbp = fbp end unless subscription_id.nil? self.subscription_id = subscription_id end unless lead_id.nil? self.lead_id = lead_id end unless f5first.nil? self.f5first = f5first end unless f5last.nil? self.f5last = f5last end unless fi.nil? self.fi = fi end unless dobd.nil? self.dobd = dobd end unless dobm.nil? self.dobm = dobm end unless doby.nil? self.doby = doby end end |
Instance Attribute Details
#city ⇒ Object
A city in lower-case without spaces or punctuation. Example: menlopark
51 52 53 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 51 def city @city end |
#client_ip_address ⇒ Object
The IP address of the browser corresponding to the event.
74 75 76 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 74 def client_ip_address @client_ip_address end |
#client_user_agent ⇒ Object
The user agent for the browser corresponding to the event.
77 78 79 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 77 def client_user_agent @client_user_agent end |
#country_code ⇒ Object
A two-letter country code in lowercase. Example: us
55 56 57 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 55 def country_code @country_code end |
#date_of_birth ⇒ Object
A date of birth given as year, month, and day. Format should be ‘YYYYMMDD’ Example: 19971226 for December 26, 1997.
39 40 41 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 39 def date_of_birth @date_of_birth end |
#dobd ⇒ Object
The date of birth day.
107 108 109 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 107 def dobd @dobd end |
#dobm ⇒ Object
The date of birth month.
110 111 112 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 110 def dobm @dobm end |
#doby ⇒ Object
THe date of birth year.
113 114 115 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 113 def doby @doby end |
#email ⇒ Object
An email address, in lowercase. Example: [email protected]
27 28 29 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 27 def email @email end |
#external_id ⇒ Object
Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs. In the Offline Conversions API (www.facebook.com/business/help/104039186799009), this is known as extern_id. For more information, see Offline Conversions, Providing External IDs. If External ID is being sent via other channels, then it should be sent in the same format via the server-side API.
71 72 73 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 71 def external_id @external_id end |
#f5first ⇒ Object
The first 5 letters of the first name.
98 99 100 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 98 def f5first @f5first end |
#f5last ⇒ Object
The first 5 letters of the last name.
101 102 103 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 101 def f5last @f5last end |
#fbc ⇒ Object
The Facebook click ID value stored in the _fbc browser cookie under your domain. See Managing fbc and fbp Parameters for how to get this value (developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters#fbc), or generate this value from a fbclid query parameter.
83 84 85 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 83 def fbc @fbc end |
#fbp ⇒ Object
The Facebook browser ID value stored in the _fbp browser cookie under your domain. See Managing fbc and fbp Parameters for how to get this value (developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters#fbc), or generate this value from a fbclid query parameter.
89 90 91 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 89 def fbp @fbp end |
#fi ⇒ Object
The first initial.
104 105 106 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 104 def fi @fi end |
#first_name ⇒ Object
A first name in lowercase. Example: joe
47 48 49 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 47 def first_name @first_name end |
#gender ⇒ Object
Gender, in lowercase. Either f or m.
34 35 36 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 34 def gender @gender end |
#last_name ⇒ Object
A last name in lowercase. Example: smith
43 44 45 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 43 def last_name @last_name end |
#lead_id ⇒ Object
The lead ID for the user in this transaction. This ID is associated with a lead generated by Facebook’s Lead Ads.
95 96 97 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 95 def lead_id @lead_id end |
#phone ⇒ Object
A phone number. Include only digits with country code, area code, and number. Example: 16505551212
31 32 33 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 31 def phone @phone end |
#state ⇒ Object
A two-letter state code in lowercase. Example: ca
59 60 61 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 59 def state @state end |
#subscription_id ⇒ Object
The subscription ID for the user in this transaction. This is similar to the order ID for an individual product.
92 93 94 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 92 def subscription_id @subscription_id end |
#zip_code ⇒ Object
A five-digit zip code for United States. For other locations, follow each country’s standards. Example: 94035 (for United States)
64 65 66 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 64 def zip_code @zip_code end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 313 def ==(o) return true if self.equal?(o) self.class == o.class && email == o.email && phone == o.phone && gender == o.gender && date_of_birth == o.date_of_birth && last_name == o.last_name && first_name == o.first_name && city == o.city && country_code == o.country_code && state == o.state && zip_code == o.zip_code && external_id == o.external_id && client_ip_address == o.client_ip_address && client_user_agent == o.client_user_agent && fbc == o.fbc && fbp == o.fbp && subscription_id == o.subscription_id && lead_id == o.lead_id && f5first == o.f5first && f5last == o.f5last && fi == o.fi && dobd == o.dobd && dobm == o.dobm && doby == o.doby end |
#build(attributes = {}) ⇒ Object
build the object using the input hash
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 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 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 217 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?(:'email') self.email = attributes[:'email'] end if attributes.has_key?(:'phone') self.phone = attributes[:'phone'] end if attributes.has_key?(:'gender') self.gender = attributes[:'gender'] end if attributes.has_key?(:'date_of_birth') self.date_of_birth = attributes[:'date_of_birth'] end if attributes.has_key?(:'last_name') self.last_name = attributes[:'last_name'] end if attributes.has_key?(:'first_name') self.first_name = attributes[:'first_name'] end if attributes.has_key?(:'city') self.city = attributes[:'city'] end if attributes.has_key?(:'country_code') self.country_code = attributes[:'country_code'] end if attributes.has_key?(:'state') self.state = attributes[:'state'] end if attributes.has_key?(:'zip_code') self.zip_code = attributes[:'zip_code'] end if attributes.has_key?(:'external_id') self.external_id = attributes[:'external_id'] end if attributes.has_key?(:'client_ip_address') self.client_ip_address = attributes[:'client_ip_address'] end if attributes.has_key?(:'client_user_agent') self.client_user_agent = attributes[:'client_user_agent'] end if attributes.has_key?(:'fbc') self.fbc = attributes[:'fbc'] end if attributes.has_key?(:'fbp') self.fbp = attributes[:'fbp'] end if attributes.has_key?(:'lead_id') self.lead_id = attributes[:'lead_id'] end if attributes.has_key?(:'f5first') self.f5first = attributes[:'f5first'] end if attributes.has_key?(:'f5last') self.f5last = attributes[:'f5last'] end if attributes.has_key?(:'fi') self.fi = attributes[:'fi'] end if attributes.has_key?(:'dobd') self.dobd = attributes[:'dobd'] end if attributes.has_key?(:'dobm') self.dobm = attributes[:'dobm'] end if attributes.has_key?(:'doby') self.doby = attributes[:'doby'] end end |
#eql?(o) ⇒ Boolean
342 343 344 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 342 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
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 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 348 def hash [ email, phone, gender, date_of_birth, last_name, first_name, city, country_code, state, zip_code, external_id, client_ip_address, client_user_agent, fbc, fbp, subscription_id, lead_id, f5first, f5last, fi, dobd, dobm, doby, ].hash end |
#normalize ⇒ Object
Normalize input fields to server request format.
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 455 def normalize hash = {} unless email.nil? hash['em'] = FacebookAds::ServerSide::Util.normalize(email, 'em') end unless phone.nil? hash['ph'] = FacebookAds::ServerSide::Util.normalize(phone, 'ph') end unless gender.nil? hash['ge'] = FacebookAds::ServerSide::Util.normalize(gender, 'ge') end unless date_of_birth.nil? hash['db'] = FacebookAds::ServerSide::Util.normalize(date_of_birth, 'db') end unless last_name.nil? hash['ln'] = FacebookAds::ServerSide::Util.normalize(last_name, 'ln') end unless first_name.nil? hash['fn'] = FacebookAds::ServerSide::Util.normalize(first_name, 'fn') end unless city.nil? hash['ct'] = FacebookAds::ServerSide::Util.normalize(city, 'ct') end unless country_code.nil? hash['country'] = FacebookAds::ServerSide::Util.normalize(country_code, 'country') end unless state.nil? hash['st'] = FacebookAds::ServerSide::Util.normalize(state, 'st') end unless zip_code.nil? hash['zp'] = FacebookAds::ServerSide::Util.normalize(zip_code, 'zp') end unless external_id.nil? hash['external_id'] = external_id end unless client_ip_address.nil? hash['client_ip_address'] = client_ip_address end unless client_user_agent.nil? hash['client_user_agent'] = client_user_agent end unless fbc.nil? hash['fbc'] = fbc end unless fbp.nil? hash['fbp'] = fbp end unless subscription_id.nil? hash['subscription_id'] = subscription_id end unless lead_id.nil? hash['lead_id'] = lead_id end unless f5first.nil? hash['f5first'] = FacebookAds::ServerSide::Util.normalize(f5first, 'f5first') end unless f5last.nil? hash['f5last'] = FacebookAds::ServerSide::Util.normalize(f5last, 'f5last') end unless fi.nil? hash['fi'] = FacebookAds::ServerSide::Util.normalize(fi, 'fi') end unless dobd.nil? hash['dobd'] = FacebookAds::ServerSide::Util.normalize(dobd, 'dobd') end unless dobm.nil? hash['dobm'] = FacebookAds::ServerSide::Util.normalize(dobm, 'dobm') end unless doby.nil? hash['doby'] = FacebookAds::ServerSide::Util.normalize(doby, 'doby') end hash end |
#to_s ⇒ String
Returns the string representation of the object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/facebook_ads/ad_objects/server_side/user_data.rb', line 379 def to_s hash = {} unless email.nil? hash['email'] = email end unless phone.nil? hash['phone'] = phone end unless gender.nil? hash['gender'] = gender end unless date_of_birth.nil? hash['date_of_birth'] = date_of_birth end unless last_name.nil? hash['last_name'] = last_name end unless first_name.nil? hash['first_name'] = first_name end unless city.nil? hash['city'] = city end unless country_code.nil? hash['country_code'] = country_code end unless state.nil? hash['state'] = state end unless zip_code.nil? hash['zip_code'] = zip_code end unless external_id.nil? hash['external_id'] = external_id end unless client_ip_address.nil? hash['client_ip_address'] = client_ip_address end unless client_user_agent.nil? hash['client_user_agent'] = client_user_agent end unless fbc.nil? hash['fbc'] = fbc end unless fbp.nil? hash['fbp'] = fbp end unless subscription_id.nil? hash['subscription_id'] = subscription_id end unless lead_id.nil? hash['lead_id'] = lead_id end unless f5first.nil? hash['f5first'] = f5first end unless f5last.nil? hash['f5last'] = f5last end unless fi.nil? hash['fi'] = fi end unless dobd.nil? hash['dobd'] = dobd end unless dobm.nil? hash['dobm'] = dobm end unless doby.nil? hash['doby'] = doby end hash.to_s end |