Skip to content

Latest commit

 

History

History
151 lines (106 loc) · 5.71 KB

EventsApi.md

File metadata and controls

151 lines (106 loc) · 5.71 KB

SajariAPIClient::EventsApi

All URIs are relative to https://api.search.io

Method HTTP request Description
send_event POST /v4/events:send Send event
send_event2 POST /v4/events:sendEvent Send event

send_event

Object send_event(account_id, send_event_request)

Send event

Send an event to the ranking system after a user interacts with a search result. When querying a collection, you can set the tracking type of the query request. When it is CLICK or POS_NEG, a token is generated for each result in the query response. You can use this token to provide feedback to the ranking system. Each time you want to record an event on a particular search result, use the send event call and provide: - The name of the event, e.g. click, redirect, purchase. - The token from the search result. - The weight to assign to the event, e.g. 1. - An object containing any additional metadata. For example, to send an event where a customer purchased a product, use the following call: json { \"name\": \"purchase\", \"token\": \"eyJ...\", \"weight\": 1, \"metadata\": { \"discount\": 0.2, \"margin\": 30.0, \"customer_id\": \"12345\", \"ui_test_segment\": \"A\" } } When sending event tokens returned from redirects, set name to redirect. Note: You must pass an Account-Id header.

Examples

require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
  # Configure HTTP basic authorization: BasicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'
end

api_instance = SajariAPIClient::EventsApi.new
account_id = 'account_id_example' # String | The account that owns the collection, e.g. `1618535966441231024`.
send_event_request = SajariAPIClient::SendEventRequest.new({name: 'name_example', token: 'token_example'}) # SendEventRequest | 

begin
  # Send event
  result = api_instance.send_event(account_id, send_event_request)
  p result
rescue SajariAPIClient::ApiError => e
  puts "Error when calling EventsApi->send_event: #{e}"
end

Using the send_event_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(Object, Integer, Hash)> send_event_with_http_info(account_id, send_event_request)

begin
  # Send event
  data, status_code, headers = api_instance.send_event_with_http_info(account_id, send_event_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => Object
rescue SajariAPIClient::ApiError => e
  puts "Error when calling EventsApi->send_event_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
account_id String The account that owns the collection, e.g. `1618535966441231024`.
send_event_request SendEventRequest

Return type

Object

Authorization

BasicAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

send_event2

Object send_event2(send_event_request)

Send event

Send an event to the ranking system after a user interacts with a search result. When querying a collection, you can set the tracking type of the query request. When it is CLICK or POS_NEG, a token is generated for each result in the query response. You can use this token to provide feedback to the ranking system. Each time you want to record an event on a particular search result, use the send event call and provide: - The name of the event, e.g. click, redirect, purchase. - The token from the search result. - The weight to assign to the event, e.g. 1. - An object containing any additional metadata. For example, to send an event where a customer purchased a product, use the following call: json { \"name\": \"purchase\", \"token\": \"eyJ...\", \"weight\": 1, \"metadata\": { \"discount\": 0.2, \"margin\": 30.0, \"customer_id\": \"12345\", \"ui_test_segment\": \"A\" } } When sending event tokens returned from redirects, set name to redirect. Note: You must pass an Account-Id header.

Examples

require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
  # Configure HTTP basic authorization: BasicAuth
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'
end

api_instance = SajariAPIClient::EventsApi.new
send_event_request = SajariAPIClient::SendEventRequest.new({name: 'name_example', token: 'token_example'}) # SendEventRequest | 

begin
  # Send event
  result = api_instance.send_event2(send_event_request)
  p result
rescue SajariAPIClient::ApiError => e
  puts "Error when calling EventsApi->send_event2: #{e}"
end

Using the send_event2_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(Object, Integer, Hash)> send_event2_with_http_info(send_event_request)

begin
  # Send event
  data, status_code, headers = api_instance.send_event2_with_http_info(send_event_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => Object
rescue SajariAPIClient::ApiError => e
  puts "Error when calling EventsApi->send_event2_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
send_event_request SendEventRequest

Return type

Object

Authorization

BasicAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json