tracker

Interface to tracking related API calls
Source:
Returns:
Type:
object

Methods

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

Subscribe to success or error messages emitted by tracking requests
Source:
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
Example
constructorio.tracker.on('error', (data) => {
    // Handle tracking error
});

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

User selected (clicked, or navigated to via keyboard) a result that appeared within autocomplete
Source:
Parameters:
Name Type Attributes Description
term string Term of selected autocomplete item
parameters object Additional parameters to be sent with request
Name Type Attributes Description
original_query 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.)
group_id string <optional>
Group identifier of selected item
display_name string <optional>
Display name of group of selected item
networkParameters object <optional>
Parameters relevant to the network request
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackAutocompleteSelect(
    'T-Shirt',
     {
         original_query: 'Shirt',
         section: 'Products',
         tr: 'click',
         group_id: '88JU230',
         display_name: 'apparel',
     },
);

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

User clicked a result that appeared within a browse product listing page
Source:
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Name Type Attributes Default Description
filter_name string Filter name
filter_value string Filter value
item_id string Product item unique identifier
section string <optional>
"Products" Index section
variation_id string <optional>
Product item variation unique identifier
result_id string <optional>
Browse result identifier (returned in response from Constructor)
result_count number <optional>
Total number of results
result_page number <optional>
Page number of results
result_position_on_page number <optional>
Position of clicked item
num_results_per_page number <optional>
Number of results shown
selected_filters object <optional>
Selected filters
networkParameters object <optional>
Parameters relevant to the network request
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackBrowseResultClick(
    {
        variation_id: 'KMH879-7632',
        result_id: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        result_count: 22,
        result_page: 2,
        result_position_on_page: 2,
        num_results_per_page: 12,
        selected_filters: { brand: ['foo'], color: ['black'] },
        filter_name: 'brand',
        filter_value: 'XYZ',
        item_id: 'KMH876',
    },
);

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

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

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

User performed an action indicating interest in an item (add to cart, add to wishlist, etc.)
Source:
See:
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
Name Type Attributes Default Description
item_id string Product item unique identifier
revenue number <optional>
Sale price if available, otherwise the regular (retail) price of item
item_name string <optional>
Product item name
variation_id string <optional>
Product item variation unique identifier
type string <optional>
'add_to_cart' Conversion type
is_custom_type boolean <optional>
Specify if type is custom conversion type
display_name string <optional>
Display name for the custom conversion type
result_id string <optional>
Result identifier (returned in response from Constructor)
section string <optional>
"Products" Index section
networkParameters object <optional>
Parameters relevant to the network request
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackConversion(
    'T-Shirt',
    {
        item_id: 'KMH876',
        revenue: 12.00,
        item_name: 'Red T-Shirt',
        variation_id: 'KMH879-7632',
        type: 'like',
        result_id: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        section: 'Products',
    },
);

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

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

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

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

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

User loaded an item detail page
Source:
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Name Type Attributes Description
item_name string Product item name
item_id string Product item unique identifier
variation_id string <optional>
Product item variation unique identifier
networkParameters object <optional>
Parameters relevant to the network request
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackItemDetailLoad(
    {
        item_name: 'Red T-Shirt',
        item_id: 'KMH876',
    },
);

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

User completed an order (usually fired on order confirmation page)
Source:
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Name Type Attributes Default Description
items Array.<object> List of product item objects
revenue number The subtotal (not including taxes, shipping, etc.) of the entire order
order_id string <optional>
Unique order identifier
section string <optional>
"Products" Index section
networkParameters object <optional>
Parameters relevant to the network request
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackPurchase(
    {
        items: [{ item_id: 'KMH876' }, { item_id: 'KMH140' }],
        revenue: 12.00,
        order_id: 'OUNXBG2HMA',
        section: 'Products',
    },
);

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

User clicked an item that appeared within a list of recommended results
Source:
Parameters:
Name Type Attributes Description
parameters object Additional parameters to be sent with request
Name Type Attributes Default Description
pod_id string Pod identifier
strategy_id string Strategy identifier
item_id string Product item unique identifier
item_name string Product name
variation_id string <optional>
Product item variation unique identifier
section string <optional>
"Products" Index section
result_id string <optional>
Recommendation result identifier (returned in response from Constructor)
result_count number <optional>
Total number of results
result_page number <optional>
Page number of results
result_position_on_page number <optional>
Position of result on page
num_results_per_page number <optional>
Number of results on page
networkParameters object <optional>
Parameters relevant to the network request
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackRecommendationClick(
    {
        variation_id: 'KMH879-7632',
        result_id: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
        result_count: 22,
        result_page: 2,
        result_position_on_page: 2,
        num_results_per_page: 12,
        pod_id: '019927c2-f955-4020',
        strategy_id: 'complimentary',
        item_name: 'Socks',
        item_id: 'KMH876',
    },
);

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

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

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

User clicked a result that appeared within a search product listing page
Source:
Parameters:
Name Type Attributes Description
term string Search results query term
parameters object Additional parameters to be sent with request
Name Type Attributes Description
item_name string Product item name
item_id string Product item unique identifier
variation_id string <optional>
Product item variation unique identifier
result_id string <optional>
Search result identifier (returned in response from Constructor)
item_is_convertible 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
Name Type Attributes Description
timeout number <optional>
Request timeout (in milliseconds)
Returns:
Type:
true | Error
Example
constructorio.tracker.trackSearchResultClick(
    'T-Shirt',
    {
        item_name: 'Red T-Shirt',
        item_id: 'KMH876',
        result_id: '019927c2-f955-4020-8b8d-6b21b93cb5a2',
    },
);

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

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

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

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

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

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