tracker

Description:
  • Interface to tracking related API calls
Source:
Interface to tracking related API calls

Methods

(inner) on(messageType, callback) → {true|Error}

Description:
  • Subscribe to success or error messages emitted by tracking requests
Source:
Example
constructorio.tracker.on('error', (data) => {
    // Handle tracking error
});
Parameters:
Name Type Description
messageType string Type of message to listen for ('success' or 'error')
callback function Callback to be invoked when message received
Returns:
Type
true | Error

(inner) trackAutocompleteSelect(term, parameters, networkParametersopt) → {true|Error}

Description:
  • User selected (clicked, or navigated to via keyboard) a result that appeared within autocomplete
Source:
Example
constructorio.tracker.trackAutocompleteSelect(
    'T-Shirt',
     {
        originalQuery: 'Shirt',
        section: 'Products',
        tr: 'click',
        groupId: '88JU230',
        displayName: 'apparel',
     },
);
Parameters:
Name Type Attributes Description
term string Term of selected autocomplete item
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Description
originalQuery string The current autocomplete search query
section string Section the selected item resides within
tr string <optional>
Trigger used to select the item (click, etc.)
groupId string <optional>
Group identifier of selected item
displayName string <optional>
Display name of group of selected item
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackBrowseResultClick(parameters, networkParametersopt) → {true|Error}

Description:
  • User clicked a result that appeared within a browse product listing page
Source:
Example
constructorio.tracker.trackBrowseResultClick(
    {
        variationId: 'KMH879-7632',
        resultId: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        resultCount: 22,
        resultPage: 2,
        resultPositionOnPage: 2,
        numResultsPerPage: 12,
        selectedFilters: { brand: ['foo'], color: ['black'] },
        filterName: 'brand',
        filterValue: 'XYZ',
        itemId: 'KMH876',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
filterName string Filter name
filterValue string Filter value
itemId string Product item unique identifier
itemName string Product item name
section string <optional>
"Products" Index section
variationId string <optional>
Product item variation unique identifier
resultId string <optional>
Browse result identifier (returned in response from Constructor)
resultCount number <optional>
Total number of results
resultPage number <optional>
Page number of results
resultPositionOnPage number <optional>
Position of clicked item
numResultsPerPage number <optional>
Number of results shown
selectedFilters object <optional>
Selected filters
analyticsTags object <optional>
Pass additional analytics data
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackBrowseResultsLoaded(parameters, networkParametersopt) → {true|Error}

Description:
  • User viewed a browse product listing page
Source:
Example
constructorio.tracker.trackBrowseResultsLoaded(
    {
        resultCount: 22,
        resultPage: 2,
        resultId: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        selectedFilters: { brand: ['foo'], color: ['black'] },
        sortOrder: 'ascending',
        sortBy: 'price',
        items: [{ itemId: 'KMH876' }, { itemId: 'KMH140' }],
        url: 'https://demo.constructor.io/sandbox/farmstand',
        filterName: 'brand',
        filterValue: 'XYZ',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
url string Current page URL
filterName string Filter name
filterValue string Filter value
items Array.<object> List of product item objects
section string <optional>
"Products" Index section
resultCount number <optional>
Total number of results
resultPage number <optional>
Page number of results
resultId string <optional>
Browse result identifier (returned in response from Constructor)
selectedFilters object <optional>
Selected filters
sortOrder string <optional>
Sort order ('ascending' or 'descending')
sortBy string <optional>
Sorting method
analyticsTags object <optional>
Pass additional analytics data
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackConversion(termopt, parameters, networkParametersopt) → {true|Error}

Description:
  • User performed an action indicating interest in an item (add to cart, add to wishlist, etc.)
Source:
See:
Example
constructorio.tracker.trackConversion(
    'T-Shirt',
    {
        itemId: 'KMH876',
        revenue: 12.00,
        itemName: 'Red T-Shirt',
        variationId: 'KMH879-7632',
        type: 'like',
        resultId: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        section: 'Products',
    },
);
Parameters:
Name Type Attributes Description
term string <optional>
Search results query term that led to conversion event
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
itemId string Product item unique identifier
revenue number <optional>
Sale price if available, otherwise the regular (retail) price of item
itemName string <optional>
Product item name
variationId string <optional>
Product item variation unique identifier
type string <optional>
'add_to_cart' Conversion type
isCustomType boolean <optional>
Specify if type is custom conversion type
displayName string <optional>
Display name for the custom conversion type
section string <optional>
"Products" Index section
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackGenericResultClick(parameters, networkParametersopt) → {true|Error}

Description:
  • User clicked a result that appeared outside of the scope of search / browse / recommendations
Source:
Example
constructorio.tracker.trackGenericResultClick(
    {
        itemId: 'KMH876',
        itemName: 'Red T-Shirt',
        variationId: 'KMH879-7632',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
itemId string Product item unique identifier
itemName string <optional>
Product item name
variationId string <optional>
Product item variation unique identifier
section string <optional>
"Products" Index section
analyticsTags object <optional>
Pass additional analytics data
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackInputFocus(networkParametersopt) → {true|Error}

Description:
  • User focused on search input element
Source:
Example
constructorio.tracker.trackInputFocus();
Parameters:
Name Type Attributes Description
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackItemDetailLoad(parameters, networkParametersopt) → {true|Error}

Description:
  • User loaded an item detail page
Source:
Example
constructorio.tracker.trackItemDetailLoad(
    {
        itemName: 'Red T-Shirt',
        itemId: 'KMH876',
        url: 'https://constructor.io/product/KMH876',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Description
itemName string Product item name
itemId string Product item unique identifier
url string Current page URL
analyticsTags object <optional>
Pass additional analytics data
variationId string <optional>
Product item variation unique identifier
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackPurchase(parameters, networkParametersopt) → {true|Error}

Description:
  • User completed an order (usually fired on order confirmation page)
Source:
Example
constructorio.tracker.trackPurchase(
    {
        items: [{ itemId: 'KMH876', price: 1, count: 1}, { itemId: 'KMH140', price: 1, count: 1s }],
        revenue: 12.00,
        orderId: 'OUNXBG2HMA',
        section: 'Products',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
items Array.<{itemId: (string|undefined), variationId: (string|undefined), itemName: (string|undefined), count: (number|undefined), price: (number|undefined)}> List of product item objects
revenue number The subtotal (excluding taxes, shipping, etc.) of the entire order
orderId string <optional>
Unique order identifier
section string <optional>
"Products" Index section
analyticsTags object <optional>
Pass additional analytics data
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackQuizConversion(parameters, networkParametersopt) → {true|Error}

Description:
  • User viewed a quiz results page
Source:
Example
constructorio.tracker.trackQuizConversion(
    {
        quizId: 'coffee-quiz',
        quizVersionId: '1231244',
        quizSessionId: '3123',
        itemName: 'espresso',
        variationId: '167',
        type: 'add_to_cart',
        revenue: '1.0'
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
quizId string Quiz identifier
quizVersionId string Quiz version identifier
quizSessionId string Quiz session identifier associated with this conversion event
itemId string <optional>
Product item unique identifier (Either itemId or itemName is required)
itemName string <optional>
Product item name
variationId string <optional>
Product item variation unique identifier
revenue string <optional>
Sale price if available, otherwise the regular (retail) price of item
section string <optional>
'Products' Index section
type string <optional>
'add_to_cart' Conversion type
isCustomType boolean <optional>
Specify if type is custom conversion type
displayName string <optional>
Display name for the custom conversion type
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackQuizResultClick(parameters, networkParametersopt) → {true|Error}

Description:
  • User viewed a quiz results page
Source:
Example
constructorio.tracker.trackQuizResultClick(
    {
        quizId: 'coffee-quiz',
        quizVersionId: '1231244',
        quizSessionId: '123',
        itemId: '123',
        itemName: 'espresso'
        variationId: '733431',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
quizId string Quiz identifier
quizVersionId string Quiz version identifier
quizSessionId string Quiz session identifier associated with this conversion event
itemId string <optional>
Product item unique identifier (Either itemId or itemName is required)
itemName string <optional>
Product item name
variationId string <optional>
Product variation unique identifier
section string <optional>
'Products' Index section
resultCount number <optional>
Total number of results
resultPage number <optional>
The page of the results
resultId string <optional>
Quiz result identifier (returned in response from Constructor)
resultPositionOnPage number <optional>
Position of clicked item
numResultsPerPage number <optional>
Number of results shown
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackQuizResultsLoaded(parameters, networkParametersopt) → {true|Error}

Description:
  • User viewed a quiz results page
Source:
Example
constructorio.tracker.trackQuizResultsLoaded(
    {
        quizId: 'coffee-quiz',
        quizVersionId: '1231244',
        quizSessionId: '3123',
        url: 'www.example.com',
        resultCount: 167,
        items: [{ itemId: 'KMH876', itemName: 'coffee' }, { itemId: 'KMH140', variationId: '123' }],
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
quizId string Quiz identifier
quizVersionId string Quiz version identifier
quizSessionId string Quiz session identifier associated with this conversion event
url string Current page url
items Array.<object> List of product item objects
section string <optional>
'Products' Index section
resultCount number <optional>
Total number of results
resultPage number <optional>
The page of the results
resultId string <optional>
Quiz result identifier (returned in response from Constructor)
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackRecommendationClick(parameters, networkParametersopt) → {true|Error}

Description:
  • User clicked an item that appeared within a list of recommended results
Source:
Example
constructorio.tracker.trackRecommendationClick(
    {
        variationId: 'KMH879-7632',
        resultId: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        resultCount: 22,
        resultPage: 2,
        resultPositionOnPage: 2,
        numResultsPerPage: 12,
        podId: '019927c2-f955-4020',
        strategyId: 'complimentary',
        itemId: 'KMH876',
        itemName: 'Socks',
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
podId string Pod identifier
strategyId string Strategy identifier
itemId string Product item unique identifier
itemName string Product item name
variationId string <optional>
Product item variation unique identifier
section string <optional>
"Products" Index section
resultId string <optional>
Recommendation result identifier (returned in response from Constructor)
resultCount number <optional>
Total number of results
resultPage number <optional>
Page number of results
resultPositionOnPage number <optional>
Position of result on page
numResultsPerPage number <optional>
Number of results on page
analyticsTags object <optional>
Pass additional analytics data
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackRecommendationView(parameters, networkParametersopt) → {true|Error}

Description:
  • User viewed a set of recommendations
Source:
Example
constructorio.tracker.trackRecommendationView(
    {
        items: [{ itemId: 'KMH876' }, { itemId: 'KMH140' }],
        resultCount: 22,
        resultPage: 2,
        resultId: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        url: 'https://demo.constructor.io/sandbox/farmstand',
        podId: '019927c2-f955-4020',
        numResultsViewed: 3,
    },
);
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Default Description
url string Current page URL
podId string Pod identifier
numResultsViewed number Number of results viewed
items Array.<object> <optional>
List of Product Item Objects
resultCount number <optional>
Total number of results
resultPage number <optional>
Page number of results
resultId string <optional>
Recommendation result identifier (returned in response from Constructor)
section string <optional>
"Products" Results section
analyticsTags object <optional>
Pass additional analytics data
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackSearchResultClick(term, parameters, networkParametersopt) → {true|Error}

Description:
  • User clicked a result that appeared within a search product listing page
Source:
Example
constructorio.tracker.trackSearchResultClick(
    'T-Shirt',
    {
        itemName: 'Red T-Shirt',
        itemId: 'KMH876',
        resultId: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
    },
);
Parameters:
Name Type Attributes Description
term string Search results query term
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Description
itemName string Product item name
itemId string Product item unique identifier
variationId string <optional>
Product item variation unique identifier
resultId string <optional>
Search result identifier (returned in response from Constructor)
itemIsConvertible string <optional>
Whether or not an item is available for a conversion
section string <optional>
The section name for the item Ex. "Products"
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackSearchResultsLoaded(term, parameters, networkParametersopt) → {true|Error}

Description:
  • User viewed a search product listing page
Source:
Example
constructorio.tracker.trackSearchResultsLoaded(
    'T-Shirt',
    {
        numResults: 167,
        itemIds: ['KMH876', 'KMH140', 'KMH437'],
    },
);
Parameters:
Name Type Attributes Description
term string Search results query term
parameters object Additional parameters to be sent with request
Properties
Name Type Description
numResults number Total number of results
itemIds Array.<string> List of product item unique identifiers in search results listing
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackSearchSubmit(term, parameters, networkParametersopt) → {true|Error}

Description:
  • User submitted a search (pressing enter within input element, or clicking submit element)
Source:
Example
constructorio.tracker.trackSearchSubmit(
    'T-Shirt',
    {
        originalQuery: 'Shirt',
        groupId: '88JU230',
        displayName: 'apparel',
    },
);
Parameters:
Name Type Attributes Description
term string Term of submitted autocomplete event
parameters object Additional parameters to be sent with request
Properties
Name Type Attributes Description
originalQuery string The current autocomplete search query
groupId string <optional>
Group identifier of selected item
displayName string <optional>
Display name of group of selected item
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error

(inner) trackSessionStart(networkParametersopt) → {true|Error}

Description:
  • Send session start event to API
Source:
Example
constructorio.tracker.trackSessionStart();
Parameters:
Name Type Attributes Description
networkParameters object <optional>
Parameters relevant to the network request
Properties
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type
true | Error