Functions (React Native)


activate

Declaration:

activate(siteId: string, codeVersion: string, navigator?: Navigator): void

This function is used to activate the Contextual Commerce SDK, and initiates communication with Contextual Commerce's servers.

Placement: This function must be called on app launch before any other method on the API (with the exception of subscription and registration methods) to allow the SDK to initialize itself with the provided site information.

See more

Parameters
siteId

The 5-character (alpha-numeric, case sensitive) site identifier provided to you by your Contextual Commerce Strategist.

Declaration:

siteId: string
codeVersion

The version string of your application code.

Declaration:

codeVersion: string
navigator

The Navigator object containing callbacks to navigate to the cart and product pages. This parameter is required for navigation on iOS.

Declaration:

navigator: Navigator
Returns

void

showCampaign

Declaration:

showCampaign(campaignId: string): void

Requests that Contextual Commerce show the specified campaign (or message) within this session.

Once requested, the campaign matching campaignId will be shown at the next available opportunity. As campaigns are designed with various limitations around their presentation (e.g. only showing on a product page), the campaign may not appear immediately after this call is made. The campaignId strings, used to request campaigns, can be obtained from your Contextual Commerce Strategist. 

This method is not intended for regular use and should not be called during regular customer shopping sessions. It is a business review tool that grants the ability to preview what a given Contextual Commerce campaign will look like within your application. We strongly recommend creating an easy way for trusted users to trigger this function. This will simplify the previewing and testing of new campaigns as they become available.

Placement: This function can be called any time after activate has been called.

See more

Parameters
campaignId

The id of the campaign to display.

Declaration:

campaignId: string
Returns

void


setCurrentProduct

Declaration:

setCurrentProduct(sku: String, productId: String): void

This function is used to set the variation (SKU) of product currently selected by the user.

Placement: This method must be called immediately after the trackProduct(...) method is called. This will tell Contextual Commerce which variation of the product is currently selected.

See more

Parameters
sku

Declaration:

sku: String
productId

Declaration:

productId: String
Returns

void


setRestrictionState

Declaration:

setRestrictionState(restrictionState?: RestrictionState): void

Tells Contextual Commerce to enter/exit a restricted state in which no campaign can be shown to the shopper.

his does not apply to inline campaigns, which will not be hidden while in a restricted state.

Placement: This function should be called:

  • When entering a situation whereby a campaign should not be shown.
  • When exiting a situation whereby a campaign should not be shown.
See more

Parameters
restrictionState

Optional. 

Declaration:

restrictionState: RestrictionState
Returns

void

subscribeGroupAssigned

Declaration:

subscribeGroupAssigned(groupAssignedListener: ((group: MatchingGroup) => void)): void

This function registers a callback to be notified when a matching group has been assigned.

In most cases, the handler implementation is expected to send the group assignment information to your analytics system. This allows for tracking messaging eligibility as a metric across all sessions. A GRANIFY (or similar) matching group is eligible to see messages whereas a BASELINE (or similar) group is ineligible.

Expect your handler to be invoked when a new session is started. No guarantees are made regarding the thread the handler will be invoked on.

Placement: This function can be called at any time, but it is most usefully called prior to activate to ensure a handler is registered in advance of the group assignment taking place.

Usage: The group that your handler receives when invoked is the exact group that should be reported in your analytics.

No changes are permitted on the group when reporting in your analytics. 

See more

Parameters
groupAssignedListener

The callback function that will be invoked when a group is assigned. The handler will take in a single parameter, group, which is the group that has been assigned.

Declaration:

groupAssignedListener: ((group: MatchingGroup) => void)
Returns

void

trackCart

Declaration:

trackCart(items: QuantityProduct[], currency: String): void

Notifies Contextual Commerce of the contents of the shopper's cart.

All cart information is required (rather than partial changesets) to sync the customer's cart with Contextual Commerce. Ensuring that this information is kept up to date is crucial to enable cart-related campaigns to work.

Placement: This function should be called:

  • On initial app launch.
  • After there is any change made to the cart. This includes:
    • After a purchase is completed (to clear the cart); including through the use of a "Buy It Now" or other express purchase button.
    • The removal of an item.
    • Cart item quantity changes.
    • Updated cart information from a server response (e.g. from shopping performed on the same user account on a different device).
See more

Parameters
items

A list containing carted QuantityProducts

Declaration:

items: QuantityProduct[]
currency

The local currency used for prices. Must be “USD”, unless another currency has been agreed upon by Bazaarvoice.

Declaration:

currency: String
Returns

void

trackOrder

Declaration:

trackOrder(order: Order): void

Notifies Contextual Commerce about completed purchases.

Placement: Call this function after the order has been finalized and paid (for example, when the receipt page is displayed). The data provided to Contextual Commerce must match the data provided to your analytics.

See more

Parameters
order

An object containing the details of the completed order.

Declaration:

order: Order
Returns

void

trackProduct

Declaration:

trackProduct(products: Product[], carter: Carter): void

This function is used to set the list of products currently available for selection by the user.

Placement: This function must be called after the TrackPageView component is loaded when navigating to a product page 

See more

Parameters
products

Declaration:

products: Product[]
carter

Declaration:

carter: Carter
Returns

void

Provide feedback button