- activate
- showCampaign
- setCurrentProduct
- setRestrictionState
- subscribeGroupAssigned
- trackCart
- trackOrder
- trackProduct
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.
Placement: This function can be called any time after activate has been called.
See more
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
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.
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
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.
See more
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
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
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