This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves analytics data, given the provided filtering.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getAnalyticsData(
measurementTypes: Array<MeasureNameEnum>,
options: GetAnalyticsDataOptions,
): Promise<GetAnalyticsDataResponse>;
Measurement types. Supported values:
TOTAL_SESSIONS
: All site visitor sessions.TOTAL_SALES
: All sales.TOTAL_ORDERS
: All orders.CLICKS_TO_CONTACT
: All clicks of the "contact us" button.Field options.
import { analyticsData } from "wix-analytics-data.v2";
async function getAnalyticsData(measurementTypes, options) {
try {
const result = await analyticsData.getAnalyticsData(
measurementTypes,
options,
);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.