UNPKG

@virto-commerce/front-modules-google-ecommerce-analytics

Version:

This module is designed for use with the VirtoCommerce frontend app. It provides a simple interface to initialize and use Google Analytics, allowing you to track user interactions and events on your website.

64 lines (63 loc) 3.4 kB
import type { CartType, CustomerOrderType, LineItemType, Product, VariationType, ICurrency, LoggerType } from "./types"; import type { ComputedRef } from "vue"; /** * Custom events. The items array can not be added */ type CustomEventNamesType = "place_order" | "clear_cart"; type EventParamsType = Gtag.ControlParams & Gtag.EventParams & Gtag.CustomParams; type EventParamsExtendedType = EventParamsType & { item_list_id?: string; item_list_name?: string; }; type SettingValueType = string | number | boolean | null; type DependenciesType = { isDevelopment: boolean; getModuleSettings: <T extends Record<string, string>>(settingsMapping: T) => { [K in T[keyof T]]?: SettingValueType; }; logger: LoggerType; useScriptTag: (src: string) => void; currentCurrency: ComputedRef<ICurrency>; currencyCode: string; }; declare function initModule({ getModuleSettings, isDevelopment, logger: loggerInstance, useScriptTag, currentCurrency, currencyCode: initialCurrencyCode, }: DependenciesType): void; declare function sendEvent(eventName: Gtag.EventNames | CustomEventNamesType, eventParams?: EventParamsType): void; declare function viewItemList(items?: { code: string; }[], params?: EventParamsExtendedType): void; declare function selectItem(item: Product | LineItemType, params?: EventParamsExtendedType): void; declare function viewItem(item: Product, params?: EventParamsExtendedType): void; declare function addItemToWishList(item: Product, params?: EventParamsExtendedType): void; declare function addItemToCart(item: Product | VariationType, quantity?: number, params?: EventParamsExtendedType): void; declare function addItemsToCart(items: (Product | VariationType)[], params?: EventParamsExtendedType): void; declare function removeItemsFromCart(items: LineItemType[], params?: EventParamsExtendedType): void; declare function viewCart(cart: CartType, params?: EventParamsExtendedType): void; declare function clearCart(cart: CartType, params?: EventParamsExtendedType): void; declare function beginCheckout(cart: CartType, params?: EventParamsExtendedType): void; declare function addShippingInfo(cart?: CartType, params?: EventParamsExtendedType, shipmentMethodOption?: string): void; declare function addPaymentInfo(cart?: CartType, params?: EventParamsExtendedType, paymentGatewayCode?: string): void; declare function purchase(order: CustomerOrderType, transactionId?: string, params?: EventParamsExtendedType): void; declare function placeOrder(order: CustomerOrderType, params?: EventParamsExtendedType): void; declare function search(searchTerm: string, visibleItems?: { code: string; }[], itemsCount?: number): void; export declare function useGoogleAnalyticsModule(): { sendEvent: typeof sendEvent; viewItemList: typeof viewItemList; selectItem: typeof selectItem; viewItem: typeof viewItem; addItemToWishList: typeof addItemToWishList; addItemToCart: typeof addItemToCart; addItemsToCart: typeof addItemsToCart; removeItemsFromCart: typeof removeItemsFromCart; viewCart: typeof viewCart; clearCart: typeof clearCart; beginCheckout: typeof beginCheckout; addShippingInfo: typeof addShippingInfo; addPaymentInfo: typeof addPaymentInfo; purchase: typeof purchase; placeOrder: typeof placeOrder; search: typeof search; initModule: typeof initModule; }; export {};