Skip to main content
Version: v2

Custom Properties

The Fullstory Browser API provides a way for clients to provide custom properties via a properties field. Version 1 required you to provide type annotation in the form of type suffixes. For example, the properties { myString: "Hello World"} needed to be annotated as { myString_str: "Hello World"}. This is no longer necessary for version 2. In fact, it is actually required that you omit these annotations for all custom properties.

Type Inference

All field types will be inferred from the values in the properties field unless field types are explicitly declared. Fullstory will infer all Number types contained in the properties field as a real type. For example:

FS('trackEvent', {
name: 'Product Added',
properties: {
name: 'Button Front Cardigan', // this will be inferred as a string
popup_help: true, // this will be inferred as a boolean
price: 58.99, // this will be inferred as a real
quantity: 1, // this will be inferred as a real
}
});

Optional Type Declarations

Types can be explicitly declared for any field in the properties collection via an optional schema field. For example, if you wanted to ensure the quantity property is an int, the type can be declared with a corresponding property type definition as part of the schema field:

FS('trackEvent', {
name: 'Product Added',
properties: {
cart_id: '130983678493',
name: 'Button Front Cardigan',
price: 58.99,
quantity: 1,
},
schema: {
properties: {
quantity: 'int',
},
},
});

This will ensure that Fullstory converts the quantity field to an integer for analysis.

NOTE: It is not necessary to include a schema field for every property; just the ones you want to explicitly type.

Nested types are also supported:

FS('trackEvent', {
name: 'Dogs and Cats',
properties: {
nestedField: {
tally: {
cats: 5,
dogs: 20,
},
}
},
schema: {
properties: {
nestedField: {
tally: {
dogs: 'int',
cats: 'int',
},
},
},
},
});

These are the types that can be declared and their declaration values:

TypeDeclaration Value
boolean"bool"
date"date"
integer"int"
real"real"
string"str"
array of boolean values"bools"
array of integer values"ints"
array of date values"dates"
array of real values"reals"
array of string values"strs"

Migrating from Version 1

Consider the following custom event from the version 1 API:

FS.event('Product Added', {
cart_id_str: '130983678493',
name_str: 'Button Front Cardigan',
price_real: 58.99,
quantity_real: 1,
});

To migrate to version 2, review the syntax at Analytics Events. Then, drop all type annotations:

FS('trackEvent', {
name: 'Product Added',
properties: {
cart_id: '130983678493',
name: 'Button Front Cardigan',
price: 58.99,
quantity: 1,
}
});