Skip to content

Instantly share code, notes, and snippets.

@alexsasharegan
Created November 22, 2017 19:07
Show Gist options
  • Save alexsasharegan/f457d2a07e8e9b342894ef750718bef4 to your computer and use it in GitHub Desktop.
Save alexsasharegan/f457d2a07e8e9b342894ef750718bef4 to your computer and use it in GitHub Desktop.
export type Currency = string
/**
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#product-data
*/
export interface ECommerceProductData {
/**
* The product ID or SKU (e.g. P67890). *Either this field or name must be set.
*/
id: string
/**
* The name of the product (e.g. Android T-Shirt). *Either this field or id must be set.
*/
name: string
/**
* The brand associated with the product (e.g. Google).
*/
brand?: string
/**
* The category to which the product belongs (e.g. Apparel).
* Use / as a delimiter to specify up to 5-levels of hierarchy (e.g. Apparel/Men/T-Shirts).
*/
category?: string
/**
* The variant of the product (e.g. Black).
*/
variant?: string
/**
* The price of a product (e.g. 29.20).
*/
price?: Currency
/**
* The quantity of a product (e.g. 2).
*/
quantity?: number
/**
* The coupon code associated with a product (e.g. SUMMER_SALE13).
*/
coupon?: string
/**
* The product's position in a list or collection (e.g. 2).
*/
position?: number
[key: string]: any
}
/**
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#impression-data
*/
export interface ECommerceImpressionData {
/**
* The product ID or SKU (e.g. P67890). *Either this field or name must be set.
*/
id: string
/**
* The name of the product (e.g. Android T-Shirt). *Either this field or id must be set.
*/
name: string
/**
* The list or collection to which the product belongs (e.g. Search Results)
*/
list?: string
/**
* The brand associated with the product (e.g. Google).
*/
brand?: string
/**
* The category to which the product belongs (e.g. Apparel). Use / as a delimiter to specify up to 5-levels of hierarchy (e.g. Apparel/Men/T-Shirts).
*/
category?: string
/**
* The variant of the product (e.g. Black).
*/
variant?: string
/**
* The product's position in a list or collection (e.g. 2).
*/
position?: number
/**
* The price of a product (e.g. 29.20).
*/
price?: Currency
[key: string]: any
}
/**
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#action-data
*/
export interface ECommerceActionData {
/**
* The transaction ID (e.g. T1234). *Required if the action type is purchase or refund.
*/
id: string
/**
* The store or affiliation from which this transaction occurred (e.g. Google Store).
*/
affiliation?: string
/**
* Specifies the total revenue or grand total associated with the transaction (e.g. 11.99).
* This value may include shipping, tax costs, or other adjustments to total revenue
* that you want to include as part of your revenue calculations.
* Note: if revenue is not set, its value will be automatically calculated
* using the product quantity and price fields of all products in the same hit.
*/
revenue?: Currency
/**
* The total tax associated with the transaction.
*/
tax?: Currency
/**
* The shipping cost associated with the transaction.
*/
shipping?: Currency
/**
* The transaction coupon redeemed with the transaction.
*/
coupon?: string
/**
* The list that the associated products belong to. Optional.
*/
list?: string
/**
* A number representing a step in the checkout process. Optional on checkout actions.
*/
step?: number
/**
* Additional field for checkout and checkout_option actions that can describe option information on the checkout page, like selected payment method.
*/
option?: string
[key: string]: any
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment