How the SDK works¶
The Amperity Event Streams SDK sends each event from a visitor’s browser to Amperity as it happens. A visitor does not wait on a server that you run, and the SDK does not hold events to send them later in a group.
How an event moves¶
An event moves from a browser to an event stream in four steps:
The SDK builds the event. When a page loads, or when your site calls the SDK, it builds an event that has the event name, the properties you provide, an anonymous visitor ID, a unique event ID, and context about the page and browser.
The SDK sends the event. The SDK sends each event in its own request to the Amperity collector, and it includes the stream’s write key in the request address. The write key identifies the event stream that receives the event.
The collector forwards the event. The collector checks the write key and sends the event to the Real-time API right away. It does not hold events or add data to them.
The Real-time API delivers the event. The Real-time API delivers the event to the event stream, and Amperity processes it in the same way as an event that your servers send to the API. See Event streams and event types.
When an event can’t be delivered¶
The SDK sends again an event that the collector could not accept right away, such as when the visitor’s connection drops or Amperity is busy. It waits longer between each attempt. When a visitor leaves a page, the SDK sends any event it still holds, and it saves the rest so that the next page on your site sends them. The SDK does not send an event again when Amperity rejects it with a client error, such as an unknown write key.
When to use the SDK¶
Use the SDK when events come from your customers’ browsers. Use the Real-time API when events come from your servers or from another tool, such as another customer data platform.