Class: Klaviyo::TrackIdentifyApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo_sdk/api/track_identify_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TrackIdentifyApi

Returns a new instance of TrackIdentifyApi.



19
20
21
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#identify_get(data, opts = {}) ⇒ String

Identify Profile (Legacy) This endpoint is also used to identify a profile and update its properties without an associated event. It takes as input the same payload as the above POST request, but as a base64-encoded string passed as a query parameter. NOTE: This is offered for backwards compatibility; we recommend all new implementations use the POST approach above. EXAMPLE: “‘ { "token": "PUBLIC_KEY", "properties": { "$email": "[email protected]", "$first_name": "Abraham", "$last_name": "Lincoln", "$city": "Springfield", "$region": "Illinois" } } “` Gets encoded into the following string, which is passed into the `data` parameter: `eyJ0b2tlbiI6ICJQVUJMSUNfS0VZIiwicHJvcGVydGllcyI6IHsiJGVtYWlsIjogImFicmFoYW0ubGluY29sbkBrbGF2aXlvLmNvbSIsIiRmaXJzdF9uYW1lIjogIkFicmFoYW0iLCIkbGFzdF9uYW1lIjogIkxpbmNvbG4iLCIkY2l0eSI6ICJTcHJpbmdmaWVsZCIsIiRyZWdpb24iOiAiSWxsaW5vaXMifX0K`

Parameters:

  • data (String)

    String representation of base64 encoded JSON object

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

    the optional parameters

Returns:

  • (String)


27
28
29
30
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 27

def identify_get(data, opts = {})
  data, _status_code, _headers = identify_get_with_http_info(data, opts)
  data
end

#identify_get_with_http_info(data, opts = {}) ⇒ Array<(String, Integer, Hash)>

Identify Profile (Legacy) This endpoint is also used to identify a profile and update its properties without an associated event. It takes as input the same payload as the above POST request, but as a base64-encoded string passed as a query parameter. NOTE: This is offered for backwards compatibility; we recommend all new implementations use the POST approach above. EXAMPLE: &#x60;&#x60;&#x60; { &quot;token&quot;: &quot;PUBLIC_KEY&quot;, &quot;properties&quot;: { &quot;$email&quot;: &quot;[email protected]&quot;, &quot;$first_name&quot;: &quot;Abraham&quot;, &quot;$last_name&quot;: &quot;Lincoln&quot;, &quot;$city&quot;: &quot;Springfield&quot;, &quot;$region&quot;: &quot;Illinois&quot; } } &#x60;&#x60;&#x60; Gets encoded into the following string, which is passed into the &#x60;data&#x60; parameter: &#x60;eyJ0b2tlbiI6ICJQVUJMSUNfS0VZIiwicHJvcGVydGllcyI6IHsiJGVtYWlsIjogImFicmFoYW0ubGluY29sbkBrbGF2aXlvLmNvbSIsIiRmaXJzdF9uYW1lIjogIkFicmFoYW0iLCIkbGFzdF9uYW1lIjogIkxpbmNvbG4iLCIkY2l0eSI6ICJTcHJpbmdmaWVsZCIsIiRyZWdpb24iOiAiSWxsaW5vaXMifX0K&#x60;

Parameters:

  • data (String)

    String representation of base64 encoded JSON object

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

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 37

def identify_get_with_http_info(data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackIdentifyApi.identify_get ...'
  end
  # verify the required parameter 'data' is set
  if @api_client.config.client_side_validation && data.nil?
    fail ArgumentError, "Missing the required parameter 'data' when calling TrackIdentifyApi.identify_get"
  end
  # resource path
  local_var_path = '/identify'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'data'] = data

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/html'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'String'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"TrackIdentifyApi.identify_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrackIdentifyApi#identify_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#identify_post(data, opts = {}) ⇒ String

Identify Profile This endpoint is used to track and update properties about an individual without tracking an associated event. The following data is stored in a JSON object. **JSON OBJECT STRUCTURE:** __token: string__ This is your public API key. __properties: *JSON Object or null*__ Properties of the profile to track/update. You must identify the person by their email using a $email key (or by their phone number using a ‘$phone_number` key if you have SMS-only contacts). Other than that, you can include any data you want and it can then be used to create segments of people. For example, if you wanted to create a list of people on trial plans, include a person’s plan type in this JSON object so you can use that information later. **SPECIAL FIELDS:** The Klaviyo CRM has the following special fields you can set for customer properties with the Identify endpoint, to unlock additional functionality: **$email:** string **$first_name:** string **$last_name:** string **$phone_number:** _string; eg: "+13239169023"_ **$city:** string **$region:** _string; state, or other region_ **$country:** string **$zip:** string **$image:** _string; url to a photo of a person_ **$consent:** _list of strings; eg: [‘sms’, ‘email’, ‘web’, ‘directmail’, ‘mobile’]_ EXAMPLE: “‘ { "token": "PUBLIC_KEY", "properties": { "$email": "[email protected]", "$first_name": "Abraham", "$last_name": "Lincoln", "$city": "Springfield", "$region": "Illinois" } }

Parameters:

  • data (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


91
92
93
94
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 91

def identify_post(data, opts = {})
  data, _status_code, _headers = identify_post_with_http_info(data, opts)
  data
end

#identify_post_with_http_info(data, opts = {}) ⇒ Array<(String, Integer, Hash)>

Identify Profile This endpoint is used to track and update properties about an individual without tracking an associated event. The following data is stored in a JSON object. **JSON OBJECT STRUCTURE:** __token: string__ This is your public API key. __properties: *JSON Object or null*__ Properties of the profile to track/update. You must identify the person by their email using a $email key (or by their phone number using a &#x60;$phone_number&#x60; key if you have SMS-only contacts). Other than that, you can include any data you want and it can then be used to create segments of people. For example, if you wanted to create a list of people on trial plans, include a person&#39;s plan type in this JSON object so you can use that information later. **SPECIAL FIELDS:** The Klaviyo CRM has the following special fields you can set for customer properties with the Identify endpoint, to unlock additional functionality: **$email:** string **$first_name:** string **$last_name:** string **$phone_number:** _string; eg: &quot;+13239169023&quot;_ **$city:** string **$region:** _string; state, or other region_ **$country:** string **$zip:** string **$image:** _string; url to a photo of a person_ **$consent:** _list of strings; eg: [&#39;sms&#39;, &#39;email&#39;, &#39;web&#39;, &#39;directmail&#39;, &#39;mobile&#39;]_ EXAMPLE: &#x60;&#x60;&#x60; { &quot;token&quot;: &quot;PUBLIC_KEY&quot;, &quot;properties&quot;: { &quot;$email&quot;: &quot;[email protected]&quot;, &quot;$first_name&quot;: &quot;Abraham&quot;, &quot;$last_name&quot;: &quot;Lincoln&quot;, &quot;$city&quot;: &quot;Springfield&quot;, &quot;$region&quot;: &quot;Illinois&quot; } }

Parameters:

  • data (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



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
150
151
152
153
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 101

def identify_post_with_http_info(data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackIdentifyApi.identify_post ...'
  end
  # verify the required parameter 'data' is set
  if @api_client.config.client_side_validation && data.nil?
    fail ArgumentError, "Missing the required parameter 'data' when calling TrackIdentifyApi.identify_post"
  end
  # resource path
  local_var_path = '/identify'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/html'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['data'] = data

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'String'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"TrackIdentifyApi.identify_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrackIdentifyApi#identify_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#track_get(data, opts = {}) ⇒ String

Track Profile Activity (Legacy) This endpoint is also used to track a profile’s activity. It takes as input the same payload as the above POST request, but as a base64-encoded string passed as a query parameter. NOTE: This is offered for backwards compatibility; we recommend all new implementations use the POST approach above. EXAMPLE: “‘ { "token": "PUBLIC_KEY", "event": "Ordered Product", "customer_properties": { "$email": "[email protected]" }, "properties": { "item_name": "Boots", "$value": 100 } } “` Gets encoded into the following string, which is passed into the `data` parameter: `eyJ0b2tlbiI6ICJQVUJMSUNfS0VZIiwiZXZlbnQiOiAiT3JkZXJlZEl0ZW0iLCJjdXN0b21lcl9wcm9wZXJ0aWVzIjogeyIkZW1haWwiOiAiYWJyYWhhbS5saW5jb2xuQGtsYXZpeW8uY29tIn0sInByb3BlcnRpZXMiOiB7Iml0ZW1fbmFtZSI6ICJCb290cyIsIiR2YWx1ZSI6IDEwMH19`

Parameters:

  • data (String)

    String representation of base64 encoded JSON object

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

    the optional parameters

Returns:

  • (String)


160
161
162
163
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 160

def track_get(data, opts = {})
  data, _status_code, _headers = track_get_with_http_info(data, opts)
  data
end

#track_get_with_http_info(data, opts = {}) ⇒ Array<(String, Integer, Hash)>

Track Profile Activity (Legacy) This endpoint is also used to track a profile&#39;s activity. It takes as input the same payload as the above POST request, but as a base64-encoded string passed as a query parameter. NOTE: This is offered for backwards compatibility; we recommend all new implementations use the POST approach above. EXAMPLE: &#x60;&#x60;&#x60; { &quot;token&quot;: &quot;PUBLIC_KEY&quot;, &quot;event&quot;: &quot;Ordered Product&quot;, &quot;customer_properties&quot;: { &quot;$email&quot;: &quot;[email protected]&quot; }, &quot;properties&quot;: { &quot;item_name&quot;: &quot;Boots&quot;, &quot;$value&quot;: 100 } } &#x60;&#x60;&#x60; Gets encoded into the following string, which is passed into the &#x60;data&#x60; parameter: &#x60;eyJ0b2tlbiI6ICJQVUJMSUNfS0VZIiwiZXZlbnQiOiAiT3JkZXJlZEl0ZW0iLCJjdXN0b21lcl9wcm9wZXJ0aWVzIjogeyIkZW1haWwiOiAiYWJyYWhhbS5saW5jb2xuQGtsYXZpeW8uY29tIn0sInByb3BlcnRpZXMiOiB7Iml0ZW1fbmFtZSI6ICJCb290cyIsIiR2YWx1ZSI6IDEwMH19&#x60;

Parameters:

  • data (String)

    String representation of base64 encoded JSON object

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

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 170

def track_get_with_http_info(data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackIdentifyApi.track_get ...'
  end
  # verify the required parameter 'data' is set
  if @api_client.config.client_side_validation && data.nil?
    fail ArgumentError, "Missing the required parameter 'data' when calling TrackIdentifyApi.track_get"
  end
  # resource path
  local_var_path = '/track'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'data'] = data

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/html'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'String'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"TrackIdentifyApi.track_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrackIdentifyApi#track_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#track_post(data, opts = {}) ⇒ String

Track Profile Activity This endpoint is used to track a profile’s activity. The following data is encoded in a JSON object. NOTE: an account can have up to 200 unique metrics (event types). This endpoint can accept payloads up to approximately 1MB. **JSON OBJECT STRUCTURE:** __token: string__ This is your public API key. __event: string__ Name of the event you want to track. __customer_properties: *JSON Object or null*__ Properties of the profile that triggered this event. You must identify the person by their email using a $email key (or by their phone number using a ‘$phone_number` key if you have SMS-only contacts). Other than that, you can include any data you want and it can then be used to create segments of people. For example, if you wanted to create a list of people on trial plans, include a person’s plan type in this JSON object so you can use that information later. __properties: *optional; JSON Object or null*__ Properties of this event. Any properties included here can be used for creating segments later For example, if you track an event called "Ordered Product" you could include a property for item type (e.g. image, article, etc.), size, etc. __time: *optional; 10-digit UNIX timestamp or null*__ When this event occurred. By default, Klaviyo assumes events happen when a request is made. If you’d like to track an event that happened in past, use this property. **SPECIAL FIELDS:** The Klaviyo CRM has the following special fields you can set for customer_properties with the Track endpoint, to unlock additional functionality: **$email:** string **$first_name:** string **$last_name:** string **$phone_number:** _string; eg: "+13239169023"_ **$city:** string **$region:** _string; state, or other region_ **$country:** string **$zip:** string **$image:** _string; url to a photo of a person_ **$consent:** _list of strings; eg: [‘sms’, ‘email’, ‘web’, ‘directmail’, ‘mobile’]_ You can also set the following special fields in event properties with the Track endpoint: **$event_id:** _a unique identifier for an event_ **$value:** _a numeric value to associate with this event (e.g. the dollar value of a purchase)_ EXAMPLE: “‘ { "token": "PUBLIC_KEY", "event": "Ordered Product", "customer_properties": { "$email": "[email protected]" }, "properties": { "item_name": "Boots", "$value": 100 } }

Parameters:

  • data (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


224
225
226
227
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 224

def track_post(data, opts = {})
  data, _status_code, _headers = track_post_with_http_info(data, opts)
  data
end

#track_post_with_http_info(data, opts = {}) ⇒ Array<(String, Integer, Hash)>

Track Profile Activity This endpoint is used to track a profile&#39;s activity. The following data is encoded in a JSON object. NOTE: an account can have up to 200 unique metrics (event types). This endpoint can accept payloads up to approximately 1MB. **JSON OBJECT STRUCTURE:** __token: string__ This is your public API key. __event: string__ Name of the event you want to track. __customer_properties: *JSON Object or null*__ Properties of the profile that triggered this event. You must identify the person by their email using a $email key (or by their phone number using a &#x60;$phone_number&#x60; key if you have SMS-only contacts). Other than that, you can include any data you want and it can then be used to create segments of people. For example, if you wanted to create a list of people on trial plans, include a person&#39;s plan type in this JSON object so you can use that information later. __properties: *optional; JSON Object or null*__ Properties of this event. Any properties included here can be used for creating segments later For example, if you track an event called &quot;Ordered Product&quot; you could include a property for item type (e.g. image, article, etc.), size, etc. __time: *optional; 10-digit UNIX timestamp or null*__ When this event occurred. By default, Klaviyo assumes events happen when a request is made. If you&#39;d like to track an event that happened in past, use this property. **SPECIAL FIELDS:** The Klaviyo CRM has the following special fields you can set for customer_properties with the Track endpoint, to unlock additional functionality: **$email:** string **$first_name:** string **$last_name:** string **$phone_number:** _string; eg: &quot;+13239169023&quot;_ **$city:** string **$region:** _string; state, or other region_ **$country:** string **$zip:** string **$image:** _string; url to a photo of a person_ **$consent:** _list of strings; eg: [&#39;sms&#39;, &#39;email&#39;, &#39;web&#39;, &#39;directmail&#39;, &#39;mobile&#39;]_ You can also set the following special fields in event properties with the Track endpoint: **$event_id:** _a unique identifier for an event_ **$value:** _a numeric value to associate with this event (e.g. the dollar value of a purchase)_ EXAMPLE: &#x60;&#x60;&#x60; { &quot;token&quot;: &quot;PUBLIC_KEY&quot;, &quot;event&quot;: &quot;Ordered Product&quot;, &quot;customer_properties&quot;: { &quot;$email&quot;: &quot;[email protected]&quot; }, &quot;properties&quot;: { &quot;item_name&quot;: &quot;Boots&quot;, &quot;$value&quot;: 100 } }

Parameters:

  • data (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/track_identify_api.rb', line 234

def track_post_with_http_info(data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackIdentifyApi.track_post ...'
  end
  # verify the required parameter 'data' is set
  if @api_client.config.client_side_validation && data.nil?
    fail ArgumentError, "Missing the required parameter 'data' when calling TrackIdentifyApi.track_post"
  end
  # resource path
  local_var_path = '/track'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/html'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['data'] = data

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'String'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"TrackIdentifyApi.track_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TrackIdentifyApi#track_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end