Analytics
Analytics tracking methods for the Extend SDK.
Overview
Some analytics events are automatically tracked by SDK components, while others require manual implementation. This provides flexibility in tracking user interactions while ensuring critical events are captured.
Automatic Tracking
The SDK automatically tracks these events:
- Offer Viewed - Automatically tracked when warranty offers are rendered by
Extend.buttons.render()
,Extend.buttons.renderSimpleOffer()
, andExtend.modal.open()
- Offer Clicked - User interactions with warranty offers (plan selections, button clicks)
- Modal Opened - When warranty modals are displayed via
Extend.modal.open()
- Modal Closed - When warranty modals are dismissed
Manual Tracking Methods
Extend.trackProductAddedToCart
Track when a product is added to the shopping cart. This should be called when a customer adds a product (not warranty) to their cart.
Signature
Extend.trackProductAddedToCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
productId |
string |
Yes | Product identifier (referenceId) |
productQuantity |
number |
Yes | Quantity added |
token |
string |
No | Optional token |
Example
// Track product added to cart
Extend.trackProductAddedToCart({
productId: 'product-123',
productQuantity: 1
})
Extend.trackOfferAddedToCart
Track when a warranty offer is added to the shopping cart. This should be called when a customer selects and adds a warranty plan to their cart.
Signature
Extend.trackOfferAddedToCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
referenceId |
string |
Yes | Product SKU the warranty is for |
planId |
string |
Yes | Selected warranty plan ID |
offerType |
object (OfferType) |
Yes | Context where offer was added |
quantity |
number |
No | Warranty quantity (default: 1) |
Example
// Track warranty added from product page
function addWarrantyToCart(planId, productSku, quantity) {
// Add to your cart system
yourCart.addWarranty(planId, quantity)
// Track with Extend
Extend.trackOfferAddedToCart({
referenceId: productSku,
planId: planId,
offerType: {
area: 'product_page',
component: 'buttons'
},
quantity: quantity
})
}
// Track warranty added from modal
Extend.modal.open({
referenceId: 'product-123',
price: 29999,
category: 'Electronics',
onClose: function(plan, product) {
if (plan) {
addWarrantyToCart(plan.planId, product.referenceId, 1)
Extend.trackOfferAddedToCart({
referenceId: product.referenceId,
planId: plan.planId,
offerType: {
area: 'product_page',
component: 'modal'
}
})
}
}
})
Extend.trackCartCheckout
Capture 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 localStorage once this method is called after the user checks out.
Signature
Extend.trackCartCheckout(cartCheckoutEvent?)
Parameters
Property | Type | Required | Description |
---|---|---|---|
cartTotal |
number |
No | Total cart value for revenue tracking |
Example
// Track checkout with cart total
function proceedToCheckout() {
const cartTotal = yourCart.getTotal()
Extend.trackCartCheckout({
cartTotal: cartTotal
})
// Proceed to checkout
window.location.href = '/checkout'
}
// Track checkout without cart total
function proceedToCheckout() {
Extend.trackCartCheckout()
// Proceed to checkout
window.location.href = '/checkout'
}
Extend.trackOfferViewed
Track when warranty offers are viewed. This is automatically tracked by SDK components, but can also be called manually for custom implementations.
Signature
Extend.trackOfferViewed(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
productId |
string |
Yes | Product SKU |
offerType |
object (OfferType) |
Yes | Context where offer was viewed |
Example
// Manual offer view tracking (usually automatic)
Extend.trackOfferViewed({
productId: 'product-123',
offerType: {
area: 'product_page',
component: 'buttons'
}
})
Extend.trackOfferUpdated
Track when a warranty offer quantity is updated in the cart.
Signature
Extend.trackOfferUpdated(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
productId |
string |
Yes | Product SKU the warranty is for |
planId |
string |
Yes | Warranty plan ID |
updates |
object (OfferUpdates) |
Yes | Updated quantities |
updates.warrantyQuantity |
number |
No | New warranty quantity |
updates.productQuantity |
number |
No | New product quantity |
Example
Extend.trackOfferUpdated({
productId: 'product-123',
planId: 'plan-456',
updates: {
warrantyQuantity: 2,
productQuantity: 2
}
})
Extend.trackOfferRemovedFromCart
Track when a warranty offer is removed from the cart.
Signature
Extend.trackOfferRemovedFromCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
productId |
string |
Yes | Product SKU the warranty was for |
planId |
string |
Yes | Warranty plan ID |
token |
string |
No | Optional token |
Example
Extend.trackOfferRemovedFromCart({
productId: 'product-123',
planId: 'plan-456'
})
Extend.trackProductUpdated
Track when a product quantity is updated in the cart.
Signature
Extend.trackProductUpdated(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
productId |
string |
Yes | Product identifier (referenceId) |
updates |
object (ProductUpdates) |
Yes | Updated quantities |
updates.productQuantity |
number |
Yes | New product quantity |
Example
Extend.trackProductUpdated({
productId: 'product-123',
updates: {
productQuantity: 3
}
})
Extend.trackProductRemovedFromCart
Track when a product is removed from the cart.
Signature
Extend.trackProductRemovedFromCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
productId |
string |
Yes | Product identifier (referenceId) |
token |
string |
No | Optional token |
Example
Extend.trackProductRemovedFromCart({
productId: 'product-123'
})
Extend.trackLinkClicked
Track when users click on warranty-related links.
Signature
Extend.trackLinkClicked(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
linkEvent |
string (LinkEvent) |
Yes | Type of link event |
productId |
string |
Yes | Product identifier (referenceId) |
linkType |
object (LinkType) |
Yes | Link context information |
Example
Extend.trackLinkClicked({
linkEvent: 'learn_more_clicked',
productId: 'product-123',
linkType: {
area: 'product_page',
component: 'learn_more_info_link'
}
})
Extend.trackPlatformCartInfo
Track platform-specific cart information.
Signature
Extend.trackPlatformCartInfo(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
platformCartId |
string |
No | Platform-specific cart ID |
platform |
string |
No | Platform name (e.g., ‘shopify’, ‘WooCommerce’) |
Example
Extend.trackPlatformCartInfo({
platformCartId: 'cart_12345',
platform: 'shopify'
})
Shipping Protection Analytics
Extend.trackSPOfferAddedToCart
Track when shipping protection is added to cart.
Signature
Extend.trackSPOfferAddedToCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
quote |
object (ShippingOffersQuote) |
Yes | Shipping protection quote |
products |
object[] (ShippingOffersItem) |
Yes | Cart items being protected |
Example
Extend.shippingProtection.render({
selector: '#shipping-protection',
items: cartItems,
isShippingProtectionInCart: false,
onEnable: function(quote) {
// Add to cart
addShippingProtectionToCart(quote)
// Track analytics
Extend.trackSPOfferAddedToCart({
quote: quote,
products: cartItems
})
}
})
Extend.trackSPOfferRemovedFromCart
Track when shipping protection is removed from cart.
Signature
Extend.trackSPOfferRemovedFromCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
quote |
object (ShippingOffersQuote) |
Yes | Shipping protection quote |
products |
object[] (ShippingOffersItem) |
Yes | Cart items that were protected |
Example
Extend.shippingProtection.render({
selector: '#shipping-protection',
items: cartItems,
isShippingProtectionInCart: true,
onDisable: function(quote) {
// Remove from cart
removeShippingProtectionFromCart()
// Track analytics
Extend.trackSPOfferRemovedFromCart({
quote: quote,
products: cartItems
})
}
})
Extend.trackSPVariant
Track shipping protection variant changes.
Signature
Extend.trackSPVariant(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
quote |
object (ShippingOffersQuote) |
Yes | Shipping protection quote |
variant |
ProductVariant |
Yes | Product variant information |
ProductVariant
interface ProductVariant {
id: number
price: string
}
Example
Extend.trackSPVariant({
quote: shippingQuote,
variant: {
id: 12345,
price: '29.99'
}
})
Extend.trackSPOfferUpdatedInCart
Track when shipping protection is updated in the cart.
Signature
Extend.trackSPOfferUpdatedInCart(options)
Parameters
Property | Type | Required | Description |
---|---|---|---|
items |
object[] (ShippingOffersItem) |
Yes | Updated cart items |
quote |
object (ShippingOffersQuote) |
Yes | Updated shipping protection quote |
oldQuoteId |
string |
No | Previous quote ID |
oldPremium |
number |
No | Previous premium amount |
Example
Extend.trackSPOfferUpdatedInCart({
items: updatedCartItems,
quote: newShippingQuote,
oldQuoteId: 'old-quote-123',
oldPremium: 599
})
Integration Patterns
E-commerce Tracking
// Configure SDK with debug mode for development
Extend.config({
storeId: 'YOUR_STORE_ID'
})
// Enable debug mode to see analytics events in console
Extend.setDebug(true)
// Product page - track product and warranty additions
function handleAddToCart() {
const product = getCurrentProduct()
const component = Extend.buttons.instance('#extend-offer')
const warranty = component?.getPlanSelection()
// Track product addition
Extend.trackProductAddedToCart({
productId: product.sku,
productQuantity: 1
})
// Track warranty addition if selected
if (warranty) {
Extend.trackOfferAddedToCart({
productId: product.sku,
productQuantity: 1,
warrantyQuantity: 1,
planId: warranty.planId,
offerType: {
area: 'product_page',
component: 'buttons'
}
})
}
// Add to cart
addToCart(product, warranty)
}
// Cart page - track shipping protection
function initializeShippingProtection() {
Extend.shippingProtection.render({
selector: '#shipping-protection',
items: getCartItems(),
isShippingProtectionInCart: hasShippingProtection(),
onEnable: function(quote) {
addShippingProtectionToCart(quote)
Extend.trackSPOfferAddedToCart({
quote: quote,
products: getCartItems()
})
},
onDisable: function(quote) {
removeShippingProtectionFromCart()
Extend.trackSPOfferRemovedFromCart({
quote: quote,
products: getCartItems()
})
}
})
}
// Checkout - track final cart state
function handleCheckout() {
const cart = getCartContents()
Extend.trackCartCheckout({
cartId: getCartId(),
products: cart.products,
offers: cart.warranties
})
// Proceed to checkout
submitCheckout()
}
Modal Tracking
// Track modal interactions
function showWarrantyModal(product) {
Extend.modal.open({
referenceId: product.sku,
price: product.price,
category: product.category,
modalOrigin: 'product_info',
onClose: function(plan, product) {
if (plan) {
// Add warranty to cart
addWarrantyToCart(plan.planId, product.referenceId, 1)
// Track addition from modal
Extend.trackOfferAddedToCart({
referenceId: product.referenceId,
planId: plan.planId,
offerType: {
area: 'product_page',
component: 'modal'
}
})
}
}
})
}
Cart Warranty Tracking
// Track cart warranty additions
Extend.buttons.renderSimpleOffer('#cart-warranty', {
referenceId: 'product-123',
price: 29999,
category: 'Electronics',
onAddToCart: function(plan, product, quantity) {
// Add to cart
addWarrantyToCart(plan.planId, quantity)
// Track addition from cart
Extend.trackOfferAddedToCart({
referenceId: product.referenceId,
planId: plan.planId,
offerType: {
area: 'cart_page',
component: 'buttons'
},
quantity: quantity
})
}
})
Type Definitions
LinkEvent
type LinkEvent = 'learn_more_clicked' | 'plan_details_clicked' | 'sp_learn_more_clicked' | 'sp_plan_details_clicked'
LinkType
interface LinkType {
area: 'product_page' | 'cart_page' | 'learn_more_modal' | 'offer_modal' | 'simple_offer_modal' | 'post_purchase_modal' | 'sp_learn_more_modal' | 'sp_offer_container'
component: 'learn_more_info_icon' | 'learn_more_info_link' | 'see_plan_details_link' | 'sp_learn_more_info_link' | 'sp_see_plan_details_link'
}
OfferType
interface OfferType {
area: 'product_page' | 'cart_page' | 'collection' | 'modal' | 'app'
component: 'buttons' | 'modal' | 'app'
}
OfferUpdates
interface OfferUpdates {
warrantyQuantity?: number
productQuantity?: number
}
ProductUpdates
interface ProductUpdates {
productQuantity: number
}
ShippingOffersItem
interface ShippingOffersItem {
referenceId: string
quantity: number
purchasePrice: number // Price in cents
productName: string
category?: string
shippable?: boolean
}
ShippingOffersQuote
interface ShippingOffersQuote {
id: string
premium: number // Premium in cents
currency: string
excludedProducts?: string[]
}
Support
For analytics implementation help, contact Extend support through the Merchant Portal.