Pages

This reference describes the JSON object data model for a recommendation configuration. Use this reference when creating and editing recommendation configurations.

You create and manage recommendation configurations in the Frosmo Control Panel or with the Graniitti API.

Frosmo Control Panel vs. Graniitti API

The Control Panel exposes only the crucial object properties, while the Graniitti API allows you to work with the full set of properties in the data model. It is recommended that you use the Control Panel by default. Use the Graniitti API only for troubleshooting or if you're creating your own application for accessing the Frosmo back end.

You can view and define the following properties in the Control Panel:

  • name (required)
  • description (optional)
  • type (required)
  • frequency (required)
  • hours (required)
  • limit (required)
  • params (required)
  • map_ids (optional)
  • options (required)
  • filters (optional)

Recommendation configuration object

The following table describes the main recommendation configuration object.

Table: Recommendation configuration object properties

PropertyDescriptionTypeRoleExample
id

Recommendation configuration ID.

The platform sets this property. You cannot change it.

NumberRequired
"id": 2030
site_id

Site ID.

The platform sets this property. You cannot change it.

NumberRequired
"site_id": 2094
name

Recommendation configuration name.

The name must be unique within the site. The platform validates the name when saving the configuration and throws an error if the name is not unique.

The default value is a randomly generated universally unique identifier (UUID). It is recommended that you change the name to something descriptive and useful for users.

StringRequired
"name": "Most viewed affordable shirts"
description

Description of the recommendation configuration. Use the description to explain what sort of recommendation the configuration generates.

The default value is Newly created recommendation.

StringOptional
"description": "Top 5 most viewed shirts in the past 14 days that cost less than 30.00"
type

Recommendation type.

The type defines the algorithm that the platform uses to generate the recommendation.

The possible values for the built-in algorithms are:

  • bundle_converted
  • bundle_viewed
  • bundle_viewed_converted
  • most_converted
  • most_viewed

The default value is most_viewed.

For more information about the algorithms, see Supported recommendation algorithms.

StringRequired
"type": "most_viewed"
status

Current status of recommendation data generation.

The possible values are (in process order):

  • new: Recommendation data generation has yet to be scheduled.
  • scheduled: Recommendation data generation has been scheduled. Depending on how many other recommendation configurations are in the queue, it might take anywhere from a fraction of a second to several minutes before the data generation starts.
  • started: Recommendation data is being generated.
  • success: Recommendation data was successfully generated.
  • failure: Recommendation data generation failed.

The default value is new.

The platform sets this property. If you use the Graniitti API to manually set this property to anything other thannew, the change has no effect on the data generation.

If you update the recommendation configuration with the Graniitti API and want to queue the configuration for immediate data generation, set this property to new.

StringRequired
"status": "success"
duration

Total number of seconds it took to generate the recommendation data.

The platform sets this property. Do not set it manually.

NumberOptional
"duration": 1
frequency

How often the recommendation data is to be regenerated.

The possible values are:

The default value is 15m.

If you enter a value not listed above and save the configuration, the platform ignores the value and retains the existing one (default value unless previously saved with another valid value).

The regeneration point in time is calculated based on the last time the data was generated (either automatically or manually). For example:

  • If the frequency is 15 minutes, and the data is generated at 10:15, the data is next generated at 10:30.
  • If the frequency is 1 day, and the data is generated at 10:15, the data is next generated at 10:15 the following day.

It is recommended that you set frequency based on hours as follows:

HoursFrequency
Less than or equal to 24 (1 day)15m
25168 (1–7 days)1h
Greater than 168 (7 days)1d

If generating the recommendation data takes longer than the defined frequency, increase the frequency, as there's no point in having a frequency that's shorter than the actual generation duration. You can check the duration after the recommendation data has been generated at least once.

StringRequired
"frequency": "1d"
hours

Amount of usage data on which to base the recommendation. The amount is in past hours of data counting from when the platform starts generating the recommendation.

For example, if you set this to 10, the platform always generates the recommendation based on the last 10 hours of usage data collected from the site.

The minimum value is 1. The maximum value is 1440 (60 days).

The default value is 1.

NumberRequired
"hours": 336
limit

Maximum number of recommended items to return.

The minimum value is 1. The maximum value is 120.

The default value is 20.

NumberRequired
"limit": 5
params

Names for the Recommendations API request parameters for filtering the recommendation results. The parameters you define here determine the parameters that you can use in a request to filter which recommended items to return.

For example, if you're creating a product recommendation and want to filter the results by product category and price, define the names for two parameters: one for category and the other for price, such as category and price.

Defining the parameters

You can filter the results by any data field. You can also filter the results by segment if the recommendation type is most_converted or most_viewed. How exactly you want to filter the results, and therefore what parameters to define for the request, is up to you.

If the recommendation type is bundle_converted, bundle_viewed, or bundle_viewed_converted, define only a single parameter: the target field against which the recommendation is generated. For example, if you want to recommend products purchased together with a product the visitor just added to their shopping cart, define a parameter for product ID, since the recommendation is based on a specific product. Do not define any other parameters.

If the recommendation type is most_converted or most_viewed, and if you want to filter the results by segment, define a parameter for segment ID as the last string in the array.

You can freely name the parameters.

You must define at least one parameter.

For product recommendations, the options.product_attrs property defines how the parameters map to product attributes in the product data.

For information about using the parameters in a request, see Recommendations API: Requests.

Array of stringsRequired

Filter recommended items by category:

"params": [
  "category"
]

Filter recommended items by category and brand:

"params": [
  "category",
  "brand"
]

Filter recommended items by category, price, and visitor segment:

"params": [
  "category",
  "price",
  "segment"
]
map_ids

Logic for mapping the IDs of the recommended items to source data in the Frosmo back end. This determines what data the recommendation actually returns for each item.

The possible values are:

  • product: Map each item ID to a product ID. Return the full product data for each ID.
  • Empty string: Do not map the item IDs to anything. Return the raw recommendation data (ID and recommendation weight) for each item.

If you're creating a product recommendation and want to return the full product data in the recommendation results, set this property to product.

The default value is product.

StringOptional

Map each item ID to a product ID:

"map_ids": "product"

Do not map the item IDs:

"map_ids": ""
options

Configuration options specific to recommendation type.

If you have no options to define, set this property to an empty object ({}).

The default value is {}.

For more information, see Options object.

ObjectRequiredFor examples, see Options object.
filters

This property is only valid for product recommendations.

Advanced product data filters for refining the set of recommended products to return.

While params define the fields and segments that you can specify in a Recommendations API request to filter the results, filters define advanced result filtering that the platform applies automatically to all requests.

You can use filters only with product attributes. If you want to filter recommendation results by segment, use params.

If you define multiple filters, the platform applies them all, that is, the platform treats the filters as combined with logical AND operators. The platform only returns items for whom all the filters evaluate to true.

The platform automatically applies filters on top of the filtering performed with params. If a request does not perform any filtering with params, the platform nonetheless applies the filters, if defined.

The default value is null.

For more information, see Filter object.

Array of filter objectsOptional

Exclude books:

"filters": [{
    "name": "Exclude books",
    "rules": [{
        "attribute": "type",
        "operator": "!=",
        "value": "Books"
    }]
}]

Only return books whose title ends with "for dummies" and that cost less than 30 (in the site currency):

"filters": [{
    "name": "Include 'For Dummies' books",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Books"
    },{
        "attribute": "name",
        "operator": "endsWith",
        "value": "for dummies"
    }]
},{
    "name": "Include items that cost < 30",
    "rules": [{
        "attribute": "price",
        "operator": "<",
        "value": "30"
    }]
}]

For more examples, see Filter examples.

model

This is a deprecated property.




error

Error trace of what happened when the recommendation data generation failed.

If the data generation was successful, the value is an empty string.

The platform sets this property. Do not set it manually.

StringOptional
"error": ""
created_at

Date and time when the recommendation configuration was created.

For more information about the date and time format, see Graniitti API: Resources.

The platform sets this property. You cannot change it.

StringRequired
"created_at": "2020-10-08T16:36:46+00:00"
updated_at

Date and time when the recommendation configuration was last updated.

For more information about the date and time format, see Graniitti API: Resources.

The platform sets this property. You cannot change it.

StringRequired
"updated_at": "2020-10-09T07:08:01+00:00"
model_updated_at

Date and time when the recommendation data was last generated.

For more information about the date and time format, see Graniitti API: Resources.

The platform sets this property. Do not set it manually.

StringRequired
"model_updated_at": "2020-10-09T07:07:42+00:00"
model_version

Version of the data schema used by the platform to generate and structure the recommendation data.

The current and only supported version is 2.

The platform sets this property. You cannot change it.

NumberRequired
"model_version": 2

Options object

The following table describes the options object. The object contains the configuration options specific to recommendation type.

Table: Options object properties

PropertyDescriptionTypeRoleExample
category_delimiter

This property is only valid for product recommendations whose type is most_converted or most_viewed.

Delimiter string by which to split the product category value. If the string is empty, the product category value is not split.

If you define a delimiter, you must include type in product_attrs.

The default value is an empty string ("").

StringOptional
"category_delimiter": "/"
min_weight

This property is only valid for recommendations whose type is bundle_converted, bundle_viewed, or bundle_viewed_converted.

Minimum data point weight for including the data point (item) in the recommendation results.

For bundle product recommendations, a data point is a single recommended product, and the data point weight is the total number of times the product was purchased or viewed together with other products.

The default value is 0, meaning all data points are returned.

NumberOptional
"min_weight": 10
product_attrs

This property is only valid for product recommendations.

Names of the product attributes by which to filter the recommendation results when using request parameters.

Define the names of the product attributes that correspond to the request parameters defined in the params array. You must define a matching product attribute name for every parameter (except for the final segment parameter, if defined) and in the order in which the parameters are defined in params. The names must match actual product attributes in the product data stored for your site.

To find out the available product attributes, use the Product API.

The attribute names are based on the product object properties of a Product API response.

To reference a property, whether a direct property of the product object, such as name, or a child property of the attributes object, such as price, simply use the property's name.

To reference within an array or object property of the attributes object, use dot or bracket notation (propertyName.nestedName or propertyName['nestedName']) or index notation (propertyName[i]) as appropriate, depending on the nesting structure leading up to the target element or property.

The product_attrs array tells the platform how to map the parameters in the Recommendations API request to product attributes in the product data stored for the site.

For example, if you've defined a request parameter for product category, define type as the product attribute name to which the parameter maps, since type is the product attribute for product category or type.

You must define at least one product attribute name (corresponding to the one minimum request parameter in params).

Array of stringsRequired

One request parameter defined. Map the parameter to product category:

"product_attrs": [
  "type"
]

Two request parameters defined. Map the first parameter to product category and the second parameter to product brand:

"product_attrs": [
  "type",
  "manufacturer"
]

No request parameters defined. Map nothing.

"product_attrs": []
segments

This property is only valid for recommendations whose type is most_converted or most_viewed.

IDs of the segments by which you want to allow the recommendation results to be filtered. You can use the IDs in Recommendations API requests (as the value of the segment parameter) to retrieve the recommendations only for a given segment.

If you define one or more segment IDs, the params property must include a single parameter for segment ID as its last item.

If you do not define the ID of a given segment, you cannot filter the results by that segment.

For example, if you define segment as the last item in the params property, and you define the segment IDs 123 and 456 in this property, you can use either "segment": "123" or "segment": "456" as a parameter in a Recommendations API request to filter the returned items by the corresponding segment. You could not use the parameter "segment": "789", for example, since you did not define the segment ID 789.

The segment IDs are numbers, such as 123, without the sgmt_ string prefix that you see as part of segment IDs in the Control Panel.

The default value is [].

Array of numbersOptional

Allow filtering by two segments:

"segments": [
  123,
  456
]

Do not allow filtering by any segment:

"segments": []

Filter object

The following table describes the filter object of the filters array. A filter defines a single rule set for filtering recommended products.

Table: Filter object properties

PropertyDescriptionTypeRoleExample
nameFilter name.StringRequired
"name": "Exclude books"
rules

One or more rules that together define the filtering logic for the filter.

If you define multiple rules, the platform applies them all, that is, the platform treats the rules as combined with logical AND operators. The platform only returns products for whom all the rules evaluate to true.

For more information, see Filter rule object.

Array of filter rule objectsRequired
"rules": [{
    "attribute": "type",
    "operator": "!=",
    "value": "Books"
}]

Filter rule object

The following table describes the filter rule object of the rules array. A filter rule defines a single comparison operation that is used to include or exclude products from the recommendation results.

Table: Filter rule object properties

PropertyDescriptionTypeRoleExample
attributeName of the product attribute used for filtering products.StringRequired
"attribute": "type"
operator

Relational operator used to compare the value of the product attribute defined in attribute to the value defined in value.

The comparison is case insensitive.

The platform supports the following operators:

  • =
  • !=
  • <
  • >
  • <=
  • >=
  • startsWith
  • endsWith
  • contains
  • in (value must be a JSON-stringified array)
  • notIn (value must be a JSON-stringified array)
  • regex

By default, the platform treats the product attribute and value as strings. If the product attribute is price or quantity, and if the operator is <, >, <=, or >=, the platform treats the product attribute and value as numbers, not as strings, for comparison purposes.

For regular expressions (regex), use the RE2 syntax.

StringRequired
"operator": "!="
value

Value against which the value of the product attribute defined in attribute is compared.

The value can be either a regular string or, if the operator is in or notIn, a JSON-stringified array.

StringRequired

Compare against a regular string:

"value": "Books"

Compare against a JSON-stringified array:

"value": "[\"Books\",\"Magazines\"]"

Filter examples

Here are some examples showing how to create filters with different operators and how those filters get evaluated:

Filter examples: =, !=, <, >, <=, >=

Example: Return all products from the category "Books"
"filters": [{
    "name": "Include books",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Books"
    }]
}]

// Evaluation examples:
// "type": "Books" -> TRUE
// "type": "BOOKS" -> TRUE
// "type": "books" -> TRUE
// "type": "Book" -> FALSE
// "type": "Magazines" -> FALSE
Example: Return all products from the category "Books", except ones from a specific company
"filters": [{
    "name": "Include books",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Books"
    }]
},{
    "name": "Exclude Vanity Press products",
    "rules": [{
        "attribute": "company",
        "operator": "!=",
        "value": "Vanity Press"
    }]
}]

// Evaluation examples:
// "type": "Books", "company": "Random House" -> TRUE
// "type": "Books", "company": "Vanity Press" -> FALSE
// "type": "Magazines", "company": "Random House" -> FALSE
Example: Return books that cost less than 30 currency
"filters": [{
    "name": "Include books",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Books"
    }]
},{
    "name": "Include items that cost < 30",
    "rules": [{
        "attribute": "price",
        "operator": "<",
        "value": "30"
    }]
}]

// Evaluation examples:
// "type": "Books", "price": "29.99" -> TRUE
// "type": "Books", "price": "39.99" -> FALSE
// "type": "Magazines", "price": "19.99" -> FALSE

Filter examples: startsWith, endsWith, contains

Example: Return movies whose name starts with "A"
"filters": [{
    "name": "Include movies whose name starts with 'A'",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Movies"
    },{
        "attribute": "name",
        "operator": "startsWith",
        "value": "A"
    }]
}]

// Evaluation examples:
// "type": "Movies", "name": "Aliens" -> TRUE
// "type": "Movies", "name": "aliens" -> TRUE
// "type": "Movies", "name": "Tenet" -> FALSE
// "type": "Movie", "name": "Argo" -> FALSE
Example: Return books whose title ends with "for dummies" and that cost less than 30 currency
"filters": [{
    "name": "Include 'For Dummies' books",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Books"
    },{
        "attribute": "name",
        "operator": "endsWith",
        "value": "for dummies"
    }]
},{
    "name": "Include items that cost < 30",
    "rules": [{
        "attribute": "price",
        "operator": "<",
        "value": "30"
    }]
}]

// Evaluation examples:
// "type": "Books", "name": "JavaScript For Dummies", "price": "29.99" -> TRUE
// "type": "Books", "name": "Windows 10 For Dummies", "price": "39.99" -> FALSE
// "type": "Books", "name": "The Complete Idiot's Guide to JavaScript", "price": "19.99" -> FALSE
Example: Return products whose name contains "cheetah"
"filters": [{
    "name": "Include products whose name contains 'cheetah'",
    "rules": [{
        "attribute": "name",
        "operator": "contains",
        "value": "cheetah"
    }]
}]

// Evaluation examples:
// "name": "Cheetah Plushy" -> TRUE
// "name": "Living with cheetahs, as told by a cheetah lover" -> TRUE
// "name": "Operation C.H.E.E.T.A.H." -> FALSE

Filter examples: in, notIn

Example: Return hotels located in Cairo, Kochi, or La Paz
"filters": [{
    "name": "Include hotels",
    "rules": [{
        "attribute": "type",
        "operator": "in",
        "value": "[\"Hotel\",\"Hotels\"]"
    }]
},{
    "name": "Include products for Cairo, Kochi, and La Paz",
    "rules": [{
        "attribute": "city",
        "operator": "in",
        "value": "[\"Cairo\",\"Kochi\",\"La Paz\"]"
    }]
}]

// Evaluation examples:
// "type": "Hotel", "city": "Cairo" -> TRUE
// "type": "Hotels", "city": "Kochi" -> TRUE
// "type": "Hotels", "city": "LaPaz" -> FALSE
Example: Return beach volleyball events in Finland, except those in Tampere and Turku
"filters": [{
    "name": "Include Beach volleyball events",
    "rules": [{
        "attribute": "mainCategory",
        "operator": "in",
        "value": "[\"Beach Volleyball\",\"Volleyball, Beach\"]"
    }]
},{
    "name": "Include events for Finland",
    "rules": [{
        "attribute": "country",
        "operator": "=",
        "value": "Finland"
    }]
},{
    "name": "Exclude events for Tampere and Turku",
    "rules": [{
        "attribute": "city",
        "operator": "notIn",
        "value": "[\"Tampere\",\"Turku\"]"
    }]
}]

// Evaluation examples:
// "mainCategory": "Beach Volleyball", "country": "Finland", "city": "Helsinki" -> TRUE
// "mainCategory": "Beach Volleyball", "country": "Finland", "city": "Tampere" -> FALSE
// "mainCategory": "Volleyball, Beach", "country": "Finland", "city": "Turuku" -> TRUE

Filter examples: regex

The platform supports the RE2 syntax for regular expressions.

Example: Return movies whose name starts with "A" or "a" and ends in "s"
"filters": [{
    "name": "Include movies whose name starts with 'A' or 'a' and ends in 's'",
    "rules": [{
        "attribute": "type",
        "operator": "=",
        "value": "Movies"
    },{
        "attribute": "name",
        "operator": "regex",
        "value": "^[Aa]\w+s$"
    }]
}]

// Evaluation examples:
// "type": "Movies", "name": "Aliens" -> TRUE
// "type": "Movies", "name": "aliens" -> TRUE
// "type": "Movies", "name": "ALIENS" -> FALSE
// "type": "Movies", "name": "Alien" -> FALSE

Example: Recommendation configuration object

The following is a full example of a recommendation object returned by the Graniitti API.

{
  "id": 2030,
  "site_id": 2094,
  "name": "Most viewed affordable shirts",
  "description": "Top 5 most viewed shirts in the past 14 days that cost less than 30.00",
  "type": "most_viewed",
  "status": "success",
  "duration": 1,
  "frequency": "1d",
  "hours": 336,
  "limit": 5,
  "params": [
    "category",
    "brand"
  ],
  "map_ids": "product",
  "options": {
    "product_attrs": [
      "type",
      "manufacturer"
    ]
  },
  "model": null,
  "error": "",
  "created_at": "2020-09-14T08:15:31+00:00",
  "updated_at": "2020-10-08T15:45:59+00:00",
  "model_updated_at": "2020-10-08T15:45:48+00:00",
  "model_version": 2,
  "filters": [
    {
      "name": "Include shirts that cost less than 30.00",
      "rules": [
        {
          "attribute": "category",
          "operator": "contains",
          "value": "shirt"
        },
        {
          "attribute": "price",
          "operator": "<",
          "value": "30.00"
        }
      ]
    }
  ]
}

Supported recommendation algorithms

The following table describes the built-in recommendation algorithms that you can use in a recommendation configuration.

Table: Supported recommendation algorithms

NameTypeDescription
Most purchased productsmost_convertedProducts that have been purchased the most.
Most viewed productsmost_viewedProducts that have received the most views.
Products purchased togetherbundle_convertedVisitors who purchased product A also purchased products B, C, and so on.
Products viewed togetherbundle_viewedVisitors who viewed product A also viewed products B, C, and so on.
Products viewed and purchased togetherbundle_viewed_convertedVisitors who viewed and purchased product A also viewed and purchased products B, C, and so on.

While you can, in principle, use Frosmo Recommendations to generate recommendations from any data and using any recommendation algorithm, the system currently provides built-in support only for product recommendations based on the algorithms listed above. If you want to create other types of recommendations, contact Frosmo support.

Recommendation algorithms and the data layer

Recommendations rely on usage data collected from the site. The preferred way of collecting this data is through the data layer. The following table shows you what data each supported recommendation type uses for generating recommendations and which data layer object you can use to collect this data from the site.

Table: Mapping recommendation types to data layer objects

Recommendation typeSource usage dataData layer object
Most purchased productsTransactionTransaction
Most viewed productsProduct dataProduct
Products purchased togetherTransactionTransaction
Products viewed togetherProduct dataProduct
Products viewed and purchased together

Product data

Transaction

Product

Transaction