Layer 1 copy
Tutorials Custom Events and Fields

Custom Events and Fields

The goal of sending custom events and fields is to

  1. Capture key events and data points not covered by our reserved events and fields.
  2. Give your fraud prediction model more ways to distinguish between the traits and behaviors of good and bad users so that it can more accurately find fraudsters.
  3. Give your fraud prediction model more ways to distinguish between items, services, posts, etc, so that it can determine
    • which are more attractive to fraudsters
    • which are more likely created by fraudsters
  4. Give your fraud team additional, useful ways to sort through users in the console.

For example, let's say you have a voice over IP phone business, and you want to record when a user makes acall. You can create a custom event called make_call as shown.

Three fields are required in custom events: $type, $api_key, and the $user_id or $session_id which identifies the usertaking the action.

// A hypothetical custom event recording a call made
// using a number of formatted fields
{
  "$type"              : "make_call",
  "$api_key"           : "your_api_key_here",
  "$user_id"           : "billy_jones_301",
  "recipient_user_id"  : "marylee819",
  "call_duration"      : 4428
}
import sift

client = sift.Client("your_api_key_here")

# A hypothetical custom event recording a call made
# using a number of formatted fields
properties = {
  "$user_id"           : "billy_jones_301",
  "recipient_user_id"  : "marylee819",
  "call_duration"      : 4428
}

response = client.track("make_call", properties)
require "sift"

client = Sift::Client.new(:api_key => "your_api_key_here")

# A hypothetical custom event recording a call made
# using a number of formatted fields
properties = {
  "$user_id"           => "billy_jones_301",
  "recipient_user_id"  => "marylee819",
  "call_duration"      => 4428
}

response = client.track("make_call", properties)
require 'sift-php/lib/Services_JSON-1.0.3/JSON.php';
require 'sift-php/lib/SiftRequest.php';
require 'sift-php/lib/SiftResponse.php';
require 'sift-php/lib/SiftClient.php';
require 'sift-php/lib/Sift.php';

$client = new SiftClient(array('api_key' => 'your_api_key_here'));

// Sample $link_session_to_user event
$properties = array(
  '$user_id'           => 'billy_jones_301',
  'recipient_user_id'  => 'marylee819',
  'call_duration'      => 4428
);


$response = $client->track('make_call', $properties);

Naming Custom Events

In general, events sent to our Events API should describe a particular action taken by a user. We encourage starting the name of your custom eventswith a verb in present tense, e.g. add_new_connection or create_new_location.

Custom event names may only include alphanumeric characters and _.

We encouage you to adopt our naming conventions in creating custom event and custom field names. We use lower case and snake_case for all event and field names.

Special field suffixes

Send fields using our reserved suffixes when possible to take advantage of additional analysis.