The send method is used to trigger a call to the Gamesight tracking server. This causes the following actions to occur:

  • Any queued events are recorded
  • User ID associations are added into the device graph
  • Any identity mapping made for integrations with Facebook, Google, etc are saved
  • Click details are recorded for Automatic Click Measurement

The Web SDK will not make any tracking requests until you call send, so it is important to include a call to send on every page at least once (whether or not you are measuring any events).

👍

Calling send on landing pages

For best functionality, ensure that you include a call to the send method on every relevant page where the Web SDK is installed, whether or not you are recording an event. This should include:

  • Any page that you are driving users to from your marketing campaign
  • Any page where a user_id value can be set

This will ensure that Gamesight has high quality data with as full of coverage as possible.

gsght('send', '[{event_type}]', [{event_params}], [{callback}])
ArgumentTypeExampleDescription
{event_type}String (optional)'game_launch'Event type that is merged into the EventPayload object.
{event_params}EventPayload (optional){revenue_amount: '1.23'}Additional values to include in the payload for the Event.
{callback}Function (optional)() => { console.log('Send Complete') }A function to trigger once the send call has been completed

EventPayload

Below is a description of each of fields that are supported in the EventPayload object

KeyTypeExampleDescription
typeString'game_launch'The type of event to send. If the {event_type} value is provided on the send call then it is used as the type for the Event.
transaction_idString (optional)'123456-12345-234234-234234'Unique transaction ID that is used for deduplicating events, commonly used to ensure idempotency with purchase events. Gamesight enforces that only 1 event will be processed per transaction_id.
gameplay_session_idString (optional)'123456-12345-234234-234234'A unique session ID for the user's current game session. Passing this field enables Gamesight to report on session counts, playtime, and actions within a session.
revenue_amountString (optional)'9.99'Amount of revenue being reported. You must pass a revenue_currency together with this field.
revenue_currencyString (optional)'USD'Currency revenue is being reported in.
metadataObject (optional){my_key: 'value'}Arbitrary metadata to attach to the event. Must be less than 1KB when JSON encoded.
user_idString (optional)'123456789'Specify the user_id to be sent with this event. Defaults to the user_id value set via set. If a user_id value isn't set on an event, it will be recorded anonymously using the device's gsid value.
platformString'web'Set the platform for the event. Defaults to the platform option set during init.

Examples

No event

To call send without triggering an event:

gsght('send')

There are a few reasons why you might want to use the send method without an event type:

📘

Send without Events

Note that calls made to send without an event type won't show up as an event in the console and can't be used to trigger a Goal.

Single event

Below you can find a few examples of how to send a single event using the send method

// Send a single event without any additional payload
gsght('send', 'event_name')
  
// Example event including revenue data
gsght('send', 'event_name', {
  revenue_amount: '1.23',
  revenue_currency: 'usd',
  transaction_id: '123456-12345-234234-234234'
})

// Example event omitting {event_type}
gsght('send', {
  event_type: 'event_name',
  revenue_amount: '1.23',
  revenue_currency: 'usd',
  transaction_id: '123456-12345-234234-234234'
})

Multiple events

If you would like to send multiple events in a single call, you can pass an array of EventPayload objects to send.

// for multiple events as a batched call
gsght('send', [
  {EventPayload},
  {EventPayload},
])

Callbacks

If you would like to trigger some additional code or process once the event has been successfully sent to Gamesight, you can pass a callback.

// Send a single event without any additional payload
gsght('send', 'event_name', () => {
  console.log("Send complete")
})
  
// Example event including event payload
gsght('send', 'event_name', {
  revenue_amount: '1.23',
  revenue_currency: 'usd',
  transaction_id: '123456-12345-234234-234234'
}, () => {
 console.log("Send complete") 
})

// Example event using promises + async/await
await new Promise((resolve) => gsght('send', 'event_name', resolve))
console.log("Send complete")