Search.../

countSubmissions( )

Counts the number of submissions belonging to the specified forms.

Note: The Submissions API is only available in Wix Studio and Editor X.

Description

The countSubmissions() function is useful for analytics and tracking purposes. For example, if you have a contact form on your website, you can use this function to track how many submissions it receives daily, weekly, or monthly.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function countSubmissions(formIds: Array<string>, namespace: string, options: CountSubmissionsOptions): Promise<CountSubmissionsResponse>

countSubmissions Parameters

NAME
TYPE
DESCRIPTION
formIds
Array<
string
>

Form IDs which submissions should be counted.

namespace
string

The app which the form submissions belong to. For example, the namespace for the Wix Forms app is wix.form_app.form. Call getSubmission() to retrieve the namespace.

options
Optional
CountSubmissionsOptions

Returns

Return Type:

Promise<
CountSubmissionsResponse
>
NAME
TYPE
DESCRIPTION
formsSubmissionsCount
Array<
FormSubmissionsCount
>

Forms submission count.

Was this helpful?

Count submissions (dashboard page code)

Copy Code
1import { submissions } from 'wix-forms.v2';
2
3/*
4Sample formIds value: ["21bcb6c7-02b3-4ed1-b6db-7856094fac03"]
5Sample namespace value: "wix.form_app.form"
6*/
7
8export async function myCountSubmissionsFunction(formIds, namespace) {
9 try {
10 const formsSubmissionsCount = await submissions.countSubmissions(formIds, namespace);
11 console.log('Success! Forms submissions count:', formsSubmissionsCount);
12 return formsSubmissionsCount;
13 } catch (error) {
14 console.error(error);
15 // Handle the error
16 }
17}
18
19/* Promise resolves to:
20{
21 "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",
22 "totalCount": 4,
23 "unseenCount": 2
24}
25*/
Count submissions (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { submissions } from 'wix-forms.v2';
3import { elevate } from 'wix-auth';
4
5/*
6Sample formIds value: ["21bcb6c7-02b3-4ed1-b6db-7856094fac03"]
7Sample namespace value: "wix.form_app.form"
8*/
9
10export const myCountSubmissionsFunction = webMethod(Permissions.Anyone, async (formIds, namespace) => {
11 try {
12 const elevatedCountSubmissions = elevate(submissions.countSubmissions);
13 const formsSubmissionsCount = await elevatedCountSubmissions(formIds, namespace);
14 console.log('Success! Forms submissions count:', formsSubmissionsCount);
15 return formsSubmissionsCount;
16 } catch (error) {
17 console.error(error);
18 // Handle the error
19 }
20});
21
22/* Promise resolves to:
23{
24 "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",
25 "totalCount": 4,
26 "unseenCount": 2
27}
28*/