Extend Analytics SDK

The Extend Analytics SDK is used to capture the purchasing behavior of your customers, in order to provide you metrics and analytics about the performance of your Extend warranties and related products in your store.

This document outlines all of the different methods available to you on the ExtendAnalytics object. Each section includes a description of what the method does, when it should be invoked, and what parameters to provide it, as well as best practices for implementing into your website.

Table of Contents:

Installation

Add the following code inside the <head></head> tags of your website to download and instantiate the Analytics SDK.

<head>
  <script src="https://sdk.helloextend.com/extend-analytics-sdk/v1/extend-analytics-sdk.min.js"></script>
  <script>
    ExtendAnalytis.config({ storeId: '<YOUR_EXTEND_STORE_ID>' })
  </script>
</head>

For more options that can be passed to the ExtendAnalytics.config() method, see the API Reference

Browser Support

The Extend Analytics SDK currently supports the latest versions of the following browsers:

Debug Mode

The Extend Analytics SDK has a debug feature that is useful for the testing the integration of the SDK in your store. This will help you determine if you are correctly integrating with the methods in the SDK.

Debug mode can be activated in the SDK by passing in debug: true to the ExtendAnalytics.config method. When debug mode is activated, all tracking activity will not be sent to our analytics platform. All methods will log an error to the browser’s console if the methods are configured incorrectly, such as missing required arguments, incorrect quantity values, etc.

Please be sure to disable debug mode in production in order for the events to be sent to our analytics platform.

API Reference

ExtendAnalytics.config


ExtendAnalytics.config takes in a storeId and initializes the Extend Analytics SDK. This will ensure all ExtendAnalytics method calls will be tracked with your specific store identifier. You can find your Extend store identifier at merchants.extend.com.

Optionally, a debug boolean can be provided that will log any errors the Analytics SDK generates to the Javascript console. This is useful to test the SDK implementation in your store.

This method should be called upon page load or on startup of your application.

ExtendAnalytics.config({ storeId: '<YOUR_EXTEND_STORE_ID>' })

Interface

interface Config {
  storeId: string
  debug?: boolean
}

Attributes

Attribute Data type Description
storeId
required
string Your assigned Extend storeId
debug
boolean When debug is set to true, any errors that occur will be logged to the Javascript console

ExtendAnalytics.trackOfferViewed


ExtendAnalytics.trackOfferViewed takes in your product’s productId and an OfferType. This method should be called whenever an Extend warranty offer is rendered on the screen to a user.

ExtendAnalytics.trackOfferViewed({
  productId: '<PRODUCT_REFERENCE_ID>',
  offerType,
})

Interface

interface TrackOfferViewed {
  productId: string
  offerType: OfferType
}

Attributes

Attribute Data type Description
productId
required
string the ID of the product associated with the warranty being viewed
offerType
required
OfferType see OfferType

ExtendAnalytics.trackProductAddedToCart


ExtendAnalytics.trackProductAddedToCart takes in your product’s productId and the number of units the customer wishes to add to the cart, as productQuantity. This method should be called when a user adds a product to the cart.

ExtendAnalytics.trackProductAddedToCart({
  productid: '<PRODUCT_REFERENCE_ID>',
  productQuantity: '<PRODUCT_QUANTITY>',
})

Interface

interface TrackProductAdded {
  productId: string
  productQuantity: number
}

Attributes

Attribute Data type Description
productId
required
string The ID of the product in your store. Should match the referenceId used in the Create Product request to Extend
productQuantity
required
number The initial amount of units the customer added to the cart

ExtendAnalytics.trackOfferAddedToCart


ExtendAnalytics.trackOfferAddedToCart takes in your product’s productId and the productQuantity, along with the Extend warranty’s planId and offerType. This method is used to track when a customer has added an Extend warranty to the cart. Invoke this method when a customer adds an Extend warranty to the cart for a specific product.

ExtendAnalytics.trackOfferAddedToCart({
  productId: '<PRODUCT_REFERENCE_ID>',
  productQuantity: '<PRODUCT_QUANTITY>',
  planId: '<EXTEND_WARRANTY_PLAN_ID>',
  offerType: `OfferType`,
})

Interface

interface TrackOfferAddedToCart {
  productId: string
  productQuantity: number
  planId: string
  offerType: OfferType
}

Attributes

Attribute Data type Description
productId
required
string The ID of the product associated with the warranty that was added to the cart. The product ID should match the referenceId used in the Create Product request to Extend
productQuantity required number The quantity of the associated product that was added to the cart
planId
required
string The id property on the Extend warranty product returned from the Get Offers request
offerType
required
OfferType Information regarding where in the website the user selected the warranty offer. See OfferType

ExtendAnalytics.trackOfferRemovedFromCart


ExtendAnalytics.trackOfferRemovedFromCart takes the planId of the Extend warranty, and the associated productId of the product the warranty would have covered. This method is used to track when a customer has removed an Extend warranty from the cart. Invoke this method when a customer removes an Extend warranty from the cart for a specific product.

ExtendAnalytics.trackOfferRemovedFromCart({
  productId: '<PRODUCT_REFERENCE_ID>',
  planId: '<EXTEND_WARRANTY_PLAN_ID>',
})

Interface

interface TrackOfferRemovedFromCart {
  productId: string
  planId: string
}

Attributes

Attribute Data type Description
productId
required
string The ID of the product associated with the warranty that was added to the cart. The product ID should match the referenceId used in the Create Product request to Extend
planId
required
string The id property on the Extend warranty product returned from the Get Offers request

ExtendAnalytics.trackOfferUpdated


ExtendAnalytics.trackOfferUpdated takes the planId of the Extend warranty, and the associated productId of the product the warranty covers, as well as an update object containing the set of updates to apply to the warranty offer. This method is used to track when a customer increments or decrements the quantity of a warranty that has already been added to the cart. If the quantity of the warranty is updated to 0, then a ExtendAnalytics.trackOfferRemoved event is called, and further updates to this planId/productId will result in a no-op until it is re-added via ExtendAnalytics.trackOfferAddedToCart.

ExtendAnalytics.trackOfferUpdated({
  productId: '<PRODUCT_REFERENCE_ID>',
  planId: '<EXTEND_WARRANTY_PLAN_ID>',
  updates: {
    warrantyQuantity: '<NEW_WARRANTY_QUANTITY>',
    productQuantity: '<NEW_PRODUCT_QUANTITY>',
  },
})

Interface

interface TrackOfferUpdatedEvent {
  productId: string
  planId: string
  updates: {
    warrantyQuantity?: number
    productQuantity?: number
  }
}

Attributes

Attribute Data type Description
productId
required
string The ID of the product associated with the warranty that was added to the cart. The product ID should match the referenceId used in the Create Product request to Extend
planId
required
string The id property on the Extend warranty product returned from the Get Offers request
updates
required
Object The set of updates to apply to the offer. Currently, either warrantyQuantity or productQuantity are values available to be updated.

ExtendAnalytics.trackProductRemovedFromCart


ExtendAnalytics.trackProductRemovedFromCart takes the productId of the product being removed from the cart. This method is used to track when a customer removes a product from the cart that does not have a warranty offer associated with it.

ExtendAnalytics.trackProductRemovedFromCart({
  productId: '<PRODUCT_REFERENCE_ID>',
})

Interface

interface TrackProductRemovedEvent {
  productId: string
}

Attributes

Attribute Data type Description
productId
required
string The ID of the product associated with the warranty that was added to the cart. The product ID should match the referenceId used in the Create Product request to Extend

ExtendAnalytics.trackProductUpdated


ExtendAnalytics.trackProductUpdated takes the productId of the product being updated, as well as an updates object containing the set of updates to apply to the product. This method is used to track when a customer increments or decrements the quantity of a product that has already been added to the cart. The product being updated must not be associated with a warranty offer. For updating products associated with a warranty offer, see ExtendAnalytics.trackOfferUpdated

If the productQuantity passed into this method is 0, then ExtendAnalytics.trackProductRemovedFromCart is implicitly called. The product will no longer be considered tracked. and must be re-added using ExtendAnalytics.trackProductAddedToCart.

ExtendAnalytics.trackProductUpdated({
  productId: '<PRODUCT_REFERENCE_ID>',
  updates: {
    productQuantity: '<NEW_PRODUCT_QUANTITY>',
  },
})

Interface

interface TrackProductUpdatedEvent {
  productId: string
  updates: {
    productQuantity: number
  }
}

Attributes

Attribute Data type Description
productId
required
string The ID of the product associated with the warranty that was added to the cart. The product ID should match the referenceId used in the Create Product request to Extend
updates
required
Object The set of updates to apply to the product. Currently, updating the productQuantity is the only available option.

ExtendAnalytics.trackCartCheckout


ExtendAnalytics.trackCartCheckout captures the resulting set of products and warranties that were tracked in a user’s session (via trackOfferAddedToCart, trackProductAddedToCart, etc.). This method should be called whenever a customer completes a purchase. This will help track the products and Extend warranty offers sold for your store, and optionally, the total cart revenue of the items at checkout.

Note: The Analytics SDK leverages the tracked products and items in localStorage to determine what values were purchased at checkout. These values are removed from localStorages once this method is called after the user checks out.

ExtendAnalytics.trackCartCheckout({
  cartTotal: '<CART_TOTAL>',
})

Attributes

Attribute Data type Description
cartTotal
optional
number The total amount of revenue (implicitly represented as USD), of the cart at the time of checkout.

ExtendAnalytics.trackLinkClicked captures customer interactions with “Learn More” and “?” buttons and “See Plan Details” links. This method is used to record details when a customer opens the learn-more modal or navigates to Extend’s plan details page.

ExtendAnalytics.trackLinkClicked({
  linkEvent: 'LinkEvent',
  productId: '<PRODUCT_REFERENCE_ID>',
  linkType: 'LinkType',
})

Interface

interface TrackLinkClicked {
  linkEvent: LinkEvent,
  productId: string,
  linkType: LinkType,
}

Attributes

Attribute Data type Description
linkEvent
required
LinkEvent Information about what link was clicked. See LinkEvent
productId required string The ID of the product associated with the warranty that was added to the cart. The product ID should match the referenceId used in the Create Product request to Extend
linkType
required
LinkType Information about where on the website a link was clicked. See LinkType

Shared Interface and Type Glossary

OfferType

Interface

interface OfferType {
  area: OfferTypeArea
  component: OfferTypeComponent
}

Attributes

Attribute Data type Description
area
required
OfferTypeArea Predefined string indicating where the offer was rendered
component
required
OfferTypeComponent Predefined string indicating which offer type was rendered

OfferTypeArea

Type

type OfferTypeArea =
  | 'product_page'
  | 'product_modal'
  | 'collection'
  | 'cart_page'
  | 'post_purchase_modal'

OfferTypeComponent

Type

type OfferTypeComponent = 'buttons' | 'modal'

LinkEvent

Type

type LinkEvent = 'learn_more_clicked' | 'plan_details_clicked'

LinkType

Interface

interface LinkType {
  area: LinkTypeArea
  component: LinkTypeComponent
}

Attributes

Attribute Data type Description
area
required
LinkTypeArea Predefined string indicating where the link was clicked
component
required
LinkTypeComponent Predefined string indicating which link type was clicked

LinkTypeArea

Type

type LinkTypeArea =
  | 'product_page'
  | 'cart_page'
  | 'learn_more_modal'
  | 'offer_modal'
  | 'simple_offer_modal'
  | 'post_purchase_modal'

LinkTypeComponent

Type

type LinkTypeComponent = 
  | 'learn_more_info_icon'
  | 'learn_more_info_link'
  | 'see_plan_details_link'