Events
We recommend using this API endpoint when you need to create or update a collection of events at once. Note: Since our batch APIs process requests in the background, there may be a delay of ~2 mins.
post
https://app.bentonow.com
/api/v1/batch/events
Batch Import
Below is a short example in Ruby on how you may want to utilize this import to add events into the system. Whether you want to add 1 or many this endpoint should do the trick.
batch_importer.rb
1
publishable_key = "XXXX-XXXX-XXXX-XXXX"
2
secret_key = "XXXX-XXXX-XXXX-XXXX"
3
site_uuid = "XXXX-XXXX-XXXX-XXXX"
4
5
import_data = [
6
{ email: "[email protected]", type: "$custom_event", fields: {"first_name": "Jesse"}, details: {"custom_stat": 1000}},
7
{ email: "[email protected]", type: "$custom_event_with_no_details", fields: {"first_name": "Jesse", "last_name": "Hanley"}},
8
{ email: "[email protected]", type: "$custom_event_with_nothing_else"},
9
{ email: "[email protected]", type: "$purchase", fields: {"first_name": "Jesse"}, details: {"unique": {"key": "test123" }, "value": {"currency": "USD", "amount": 8000}}},
10
{ email: "[email protected]", type: "$purchase", fields: {"first_name": "Jesse"}, details: {"unique": {"key": "test123" }, "value": {"currency": "USD", "amount": 8000}, 'cart' => { 'items' => [{'product_sku': 'SKU123', 'product_name': 'Test', 'quantity': 100, 'product_price': 8000, 'product_id': '123'}], 'abandoned_checkout_url': "https://test.com" }}},
11
{ email: "[email protected]", type: "$backdated_event", date: 3.years.ago }
12
]
13
14
uri = URI.parse("https://app.bentonow.com/api/v1/batch/events")
15
16
request = Net::HTTP::Post.new(uri)
17
request.basic_auth(publishable_key, secret_key)
18
request.body = JSON.dump({site_uuid: site_uuid, events: import_data })
19
request.content_type = "application/json"
20
req_options = { use_ssl: uri.scheme == "https", }
21
22
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
23
http.request(request)
24
end
25
26
puts JSON.parse(response.body)
Copied!
Last modified 3mo ago
Copy link