> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # GetAnalyticsData # Package: analytics # Namespace: SiteAnalyticsDataService # Method link: https://dev.wix.com/docs/api-reference/business-management/analytics/data/get-analytics-data.md ## Permission Scopes: Site Analytics - read permissions: SCOPE.DC-ANALYTICS-AND-REPORTS.READ-SITE-ANALYTICS ## Introduction Retrieves analytics data, given the specified filtering. --- ## REST API ### Schema ``` Method: getAnalyticsData Description: Retrieves analytics data, given the specified filtering. URL: https://www.wixapis.com/analytics/v2/site-analytics//data Method: GET # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: dateRange, measurementTypes Method parameters: param name: dateRange | type: DateRange | description: Date range. | required: true - name: startDate | type: string | description: Custom start date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the requested `startDate` is more than 61 days before the current date, a "Do not have data for this start date" error will be returned, as only 62 days of data is stored. - name: endDate | type: string | description: Custom end date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Returned data will include all dates until the requested end date. For example, { startDate: '2024-01-01', endDate: '2024-01-03' } will return data for '2024-01-01' and '2024-01-02'. query param name: measurementTypes | type: array | description: Measurement types. | required: true - enum: - TOTAL_SALES: Total amount of money expected from all product and service sales, before deducting refunds, shipping, and fees, including both online and manual payments. - TOTAL_ORDERS: Total amount of income from sales after deducting refunds. - CLICKS_TO_CONTACT: Total amount of site sessions where a visitor clicked to contact you via WhatsApp, phone or email. - TOTAL_SESSIONS: Total amount of visitor sessions. - TOTAL_FORMS_SUBMITTED: Total amount of forms submitted. - TOTAL_UNIQUE_VISITORS: Total amount of unique visitors. query param name: timeZone | type: timeZone | description: Time zone. Return type: GetAnalyticsDataResponse - name: data | type: array | description: Analytics data per type. - name: type | type: MeasureNameEnum | description: Measurement type. - enum: - TOTAL_SALES: Total amount of money expected from all product and service sales, before deducting refunds, shipping, and fees, including both online and manual payments. - TOTAL_ORDERS: Total amount of income from sales after deducting refunds. - CLICKS_TO_CONTACT: Total amount of site sessions where a visitor clicked to contact you via WhatsApp, phone or email. - TOTAL_SESSIONS: Total amount of visitor sessions. - TOTAL_FORMS_SUBMITTED: Total amount of forms submitted. - TOTAL_UNIQUE_VISITORS: Total amount of unique visitors. - name: values | type: array | description: Data values per date. - name: date | type: string | description: Date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - name: value | type: number | description: Value. - name: total | type: number | description: Total value. ``` ### Examples ### Get site analytics data. ```curl curl -X GET \ 'https://www.wixapis.com/analytics/v2/site-analytics/data?date_range.start_date=2024-01-01&date_range.end_date=2024-01-05&measurement_types[]=TOTAL_SESSIONS&measurement_types[]=TOTAL_ORDERS' \ -H 'Content-type: application/json' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.analytics.SiteAnalyticsDataService.getAnalyticsData(measurementTypes, options) Description: Retrieves analytics data, given the specified filtering. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: options.dateRange, measurementTypes, options Method parameters: param name: measurementTypes | type: array | description: Measurement types. | required: true - enum: - TOTAL_SALES: Total amount of money expected from all product and service sales, before deducting refunds, shipping, and fees, including both online and manual payments. - TOTAL_ORDERS: Total amount of income from sales after deducting refunds. - CLICKS_TO_CONTACT: Total amount of site sessions where a visitor clicked to contact you via WhatsApp, phone or email. - TOTAL_SESSIONS: Total amount of visitor sessions. - TOTAL_FORMS_SUBMITTED: Total amount of forms submitted. - TOTAL_UNIQUE_VISITORS: Total amount of unique visitors. param name: options | type: GetAnalyticsDataOptions none | required: true - name: dateRange | type: DateRange | description: Date range. | required: true - name: startDate | type: string | description: Custom start date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. If the requested `startDate` is more than 61 days before the current date, a "Do not have data for this start date" error will be returned, as only 62 days of data is stored. - name: endDate | type: string | description: Custom end date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Returned data will include all dates until the requested end date. For example, { startDate: '2024-01-01', endDate: '2024-01-03' } will return data for '2024-01-01' and '2024-01-02'. - name: timeZone | type: string | description: Time zone. Return type: PROMISE - name: data | type: array | description: Analytics data per type. - name: type | type: MeasureNameEnum | description: Measurement type. - enum: - TOTAL_SALES: Total amount of money expected from all product and service sales, before deducting refunds, shipping, and fees, including both online and manual payments. - TOTAL_ORDERS: Total amount of income from sales after deducting refunds. - CLICKS_TO_CONTACT: Total amount of site sessions where a visitor clicked to contact you via WhatsApp, phone or email. - TOTAL_SESSIONS: Total amount of visitor sessions. - TOTAL_FORMS_SUBMITTED: Total amount of forms submitted. - TOTAL_UNIQUE_VISITORS: Total amount of unique visitors. - name: values | type: array | description: Data values per date. - name: date | type: string | description: Date in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - name: value | type: number | description: Value. - name: total | type: number | description: Total value. ``` ### Examples ### getAnalyticsData ```javascript import { analyticsData } from '@wix/analytics-data'; async function getAnalyticsData(measurementTypes,options) { const response = await analyticsData.getAnalyticsData(measurementTypes,options); }; ``` ### getAnalyticsData (with elevated permissions) ```javascript import { analyticsData } from '@wix/analytics-data'; import { auth } from '@wix/essentials'; async function myGetAnalyticsDataMethod(measurementTypes,options) { const elevatedGetAnalyticsData = auth.elevate(analyticsData.getAnalyticsData); const response = await elevatedGetAnalyticsData(measurementTypes,options); } ``` ### getAnalyticsData (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { analyticsData } from '@wix/analytics-data'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { analyticsData }, // Include the auth strategy and host as relevant }); async function getAnalyticsData(measurementTypes,options) { const response = await myWixClient.analyticsData.getAnalyticsData(measurementTypes,options); }; ``` ---