Learn how to make a Visitor API request to retrieve a visitor's affinity profile:
For more information about affinity profiles, see Feature: Affinity.
If you want to retrieve a visitor's affinity groups, see Visitor API reference (affinity groups).
Requests
URL
The URL for Visitor API requests is https://<platform_instance>/visitorApi
, where <platform_instance>
is the domain name of your Frosmo Platform instance.
To get the URL for your Frosmo Platform instance:
- Log in to the Frosmo Control Panel, and select your site.
- In the header, click your username, and select API Access.
In the Visitor API section, copy the URL.
Authentication
The Visitor API does not require authentication.
Methods
The Visitor API supports the GET HTTP method for retrieving visitor affinity profiles.
Syntax
To retrieve a visitor's affinity profile, make the following GET request:
GET https://<platform_instance>/visitorApi?method=affinityScores& origin=<site_origin>& cookieId=<local_frosmo_id>
Parameters
Table: Query parameters for Visitor API requests (affinity profiles)
Parameter | Description | Type | Role | Example |
---|---|---|---|---|
method | Request type. Use the value | String | Required | method=affinityScores |
origin | Site origin. To find out your site's origin, see Getting your site origin. | String | Required | origin=shop_company_com |
cookieId | Local Frosmo ID of the visitor whose affinity profile you want to retrieve. | String | Required | cookieId=dsr77t.kstzihlx |
limit | Maximum number of affinities to return per item attribute. The API returns the top affinities by affinity score. The minimum value is The default value is ExampleLet's assume a visitor has the following affinity profile, consisting of three { "brand": { "Cakita": 20, "Dawelt": 135, "Wakita": 328 }, "type": { "Hand Tools/Pliers": 123, "Hand Tools/Wrenches": 17, "Power Tools/Accessories": 68, "Power Tools/Drills": 170, "Power Tools/Saws": 15 } } If you retrieve the visitor's affinity profile without defining If, instead, you set { "brand": { "Dawelt": 135, "Wakita": 328 }, "type": { "Hand Tools/Pliers": 123, "Power Tools/Drills": 170 } } | Number | Optional | limit=5 |
debug | Define whether to return debugging information about the affinity profile. Use the debugging information only for development and testing purposes. Do not use the information in production, since Frosmo does not guarantee that the information structure and content will remain the same. The debugging information for an affinity profile consists of:
The possible values are:
The default value is | Boolean | Optional | debug=true |
Request examples
Responses
Success
On a success, the Visitor API returns the requested affinity profile in a JSON object. The response status code is 200
.
The response object contains the following root properties:
scores
: Object containing the affinity profile. By default, the API returns the top 10 affinities per attribute. You can override this default limit by using thelimit
parameter in the request.created_at
: Date and time when the affinity profile was created.updated_at
: Date and time when the affinity profile was last updated.debug
: Object containing the debugging information. This property is included only when thedebug
parameter is set totrue
in the request.
{ "scores": {<affinity profile>}, "created_at": <create date and time>, "updated_at": <update date and time> }
{ "scores": {<affinity profile>}, "created_at": <create date and time>, "updated_at": <update date and time>, "debug": {<debugging information>} }
Success examples
The following two examples show the same response without and with debugging information.
Error
On an error, the Visitor API returns the response status code 400
or 404
and an error message.
Table: Visitor API error messages
Error message | Description | Solution |
---|---|---|
affinity is not enabled for origin '<origin>' | The affinity feature is not enabled for the site, meaning the Frosmo Platform does not track affinities for visitors of the site. | Have Frosmo enable the affinity feature for the site. Contact Frosmo support. |
parameter 'method' missing | The method query parameter is missing from the request URL. | Provide the method query parameter. |
parameter 'method' contains an empty value | The value of the method query parameter is missing. | Provide a non-empty value for the method query parameter. |
invalid method '<parameter_value>' | The value of the method query parameter, <parameter_value> , is invalid. | Provide affinityScores as the value of the method query parameter. |
parameter 'origin' missing | The origin query parameter is missing from the request URL. | Provide the origin query parameter. |
parameter 'origin' contains an empty value | The value of the origin query parameter is missing. | Provide a non-empty value for the origin query parameter. |
invalid origin parameter '<parameter_value>' | The value of the origin query parameter, <parameter_value> , is invalid. | Provide a valid site origin as the value of the To find out your site's origin, see Getting your site origin. |
parameter 'cookieId' missing | The cookieId query parameter is missing from the request URL. | Provide the cookieId query parameter. |
parameter 'cookieId' contains an empty value | The value of the cookieId query parameter is missing. | Provide a non-empty value for the cookieId query parameter. |
parameter 'cookieId' has invalid format | The value of the cookieId query parameter has an invalid format. | Provide a value that conforms to the following rules:
|
user not found | The value of the cookieId query parameter does not match a visitor with an affinity profile. Either the visitor does not exist or the platform has yet to create an affinity profile for the visitor. | Provide a local Frosmo ID that matches a visitor with an affinity profile as the value of the cookieId query parameter. |
parameter 'limit' contains an empty value | The value of the limit query parameter is missing. | Provide a non-empty value for the limit query parameter. |
parameter 'limit' invalid, expected value greater than 0 | The value of the limit query parameter is not a positive integer. | Provide a value that respects the minimum and maximum values for the limit query parameter. |
parameter 'limit' invalid, expected value less than or equal to 30 | The value of the limit query parameter is greater than the maximum allowed value. | Provide a value that respects the minimum and maximum values for the limit query parameter. |