Counts the number of submissions belonging to the specified forms.
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.
function countSubmissions(
formIds: Array<string>,
namespace: string,
options: CountSubmissionsOptions,
): Promise<CountSubmissionsResponse>;
Form IDs which submissions should be counted.
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.
import { submissions } from "@wix/forms";
/*
Sample formIds value: ["21bcb6c7-02b3-4ed1-b6db-7856094fac03"]
Sample namespace value: "wix.form_app.form"
*/
export async function myCountSubmissionsFunction(formIds, namespace) {
try {
const formsSubmissionsCount = await submissions.countSubmissions(
formIds,
namespace,
);
console.log("Success! Forms submissions count:", formsSubmissionsCount);
return formsSubmissionsCount;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
{
"formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",
"totalCount": 4,
"unseenCount": 2
}
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.