import type { WixAnalyticsEventName, WixAnalyticsEventData } from "./types.js"; /** * Reports a [standard](https://dev.wix.com/docs/sdk/host-modules/site/events/about-analytics-events) or custom analytics event to external analytics tools connected to a site, such as Google Analytics, Facebook Pixel, or tools set up with Google Tag Manager. * * > **Note:** Wix business solutions, such as Wix Stores or Wix Events, trigger standard events when the corresponding user action occurs on the site. However, standard events aren't automatically forwarded to external analytics platforms. Call `trackEvent()` to report them to connected platforms. * * Learn more about: * * + [Marketing integrations](https://support.wix.com/en/article/about-marketing-integrations) * + [Connecting a Facebook Pixel to your wix site](https://support.wix.com/en/article/connecting-a-facebook-pixel-and-the-conversions-api-to-your-wix-site-7351813) * + [Connecting a Google Analytics property to your Wix site](https://support.wix.com/en/article/tracking-events-on-your-wix-site-with-a-google-analytics-property) * + [Connecting your Google Tag Manager account to your Wix site](https://support.wix.com/en/article/connecting-your-google-tag-manager-account-to-your-wix-site) * * @param eventName - Event name, either standard or custom. See [About Analytics Events](https://dev.wix.com/docs/sdk/host-modules/site/events/about-analytics-events) for a list of supported standard events. * @requiredField eventName * @param eventData - Event data. * @requiredField eventData * * @example Report a standard event that doesn't have event data * ```typescript * import { analytics } from '@wix/site'; * * analytics.trackEvent("Lead"); * * ``` * @example Report a standard event with event data * ```typescript * import { analytics } from '@wix/site'; * * analytics.trackEvent("ViewContent", { origin: "My Sportswear Store", id: "P12345", sku: 20, name: "Really Fast Running Shoes", price: 120, currency: "USD", category: "Apparel/Shoes", brand: "SomeBrand", variant: "Black", list: "Product Gallery", position: 1 } ); * * ``` * @example Report a custom event * ```typescript * import { analytics } from '@wix/site'; * * analytics.trackEvent("CustomEvent", { eventCategory: "Sporting Goods", eventAction: "FrequentShopper", eventLabel: "November", eventValue: 1, purchase_count: 8, average_purchase_value: 245.24, currency: "USD", shipping_info: { method: "standard overnight", note: "leave at the front door" } } ); * * ``` */ export declare function trackEvent(eventName: T, eventData?: WixAnalyticsEventData): void; /** * Reports that a button was clicked. * * Call this from your button's click handler to record the interaction. Safe to call * from any environment — it does nothing when running outside the browser. * * @example * ```typescript * import { buttonClicked } from '@wix/analytics'; * * * ``` */ export declare function buttonClicked(): void; /** * Registers an event handler that runs whenever an analytics event occurs on the site. * * Call this method to register an event handler that runs for all analytics events that occur on the site. The handler runs for both [standard events](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/analyze-user-behavior-using-embedded-scripts#listen-to-standard-wix-events) and [custom events](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/analyze-user-behavior-using-embedded-scripts#track-custom-events). * * > **Note:** To handle specific events, use conditional logic in your handler code. Learn more [about analytics events](https://dev.wix.com/docs/sdk/host-modules/site/events/about-analytics-events). * * @param eventHandler - Event handler that runs when an analytics event occurs. * @param eventHandler.eventName - Event name. Learn more about [standard analytics events](https://dev.wix.com/docs/sdk/host-modules/site/events/about-analytics-events). * @param eventHandler.eventData - Event data associated with the event. * * @example Register an event listener and display event in the console * ```typescript * import { analytics } from '@wix/site'; * * analytics.registerEventListener((eventName, eventData) => console.log(eventName, eventData) ); * * ``` */ export declare function registerEventListener(eventHandler: (eventName: T, eventData: WixAnalyticsEventData) => void): void; //# sourceMappingURL=analytics.d.ts.map