@swaarm/swaarms2s
v1.0.0
Published
SwaarmS2S is an SDK that allows developers to easily connect and send server to server events to a Swaarm platform
Downloads
2
Keywords
Readme
SwaarmS2S
SwaarmS2S is an attribution and measuring SDK that allows you to interact with the Swaarm platform through a simple API.
Installing
Usage
Before using the SDK you need to configure it in the following way:
const sdk = new SwaarmS2S(
'https://track.example.org', //This is the base url of your Swaarm tracking domain
'exmaple-token', // Replace with your actual web token
true // Optionally enable debug
);
Sending events
You can register your users' actions in Swaarm via S2S events. Say for example the user with id u1
subscribed to your
newsletter:
await sdk.event('u1', 'newsletter-subscription');
Monetary events can also be tracked, here is one example of a sale action:
await sdk.event('u1', 'sale', {revenue: 53.2, currency: 'USD'});
Custom numerical values aggregated by Swaarm in reports, as well as free-form values associated with the event can be added.
await sdk.event('u1', 'sale', {revenue: 53.2, currency: 'USD', aggregatedEventValue: 5, customValue: '{"item": "book"}'});