form

Version:

Type

Function

Import path

@sitecore-cloudsdk/events/browser

Sends a FORM event.

Signature

export async function form(
  formId: string,
  interactionType: "VIEWED" | "SUBMITTED",
  componentInstanceId: string,
): Promise<EPResponse | null>

Parameters

Name

Type

Description

Value

formId

string

Required.

The UUID of the SitecoreAI form.

To find the form ID in SitecoreAI Forms, click the form, then click Settings. The form ID is in the Form ID field.

"0c0910e5-5197-4dcf-8993-677e70bcb531"

interactionType

string

Required.

The interaction the site visitor has with the form.

Format: uppercase.

Must be one of:

  • "VIEWED"

  • "SUBMITTED"

componentInstanceId

string

Required.

The UUID of the component that contains the SitecoreAI form. Used for A/B/n testing.

"ac4109f5-9831-4abef-8005-647c70bfba01"

Return value

Returns a promise or null.

Examples

Example 34. Running the form function

Next.js

Note

To run this function, you have to first initialize the Cloud SDK.

See more examples.

Here's an example of how to use the form function:

"use client"; // Used only in Next.js App Router
import { form } from "@sitecore-cloudsdk/events/browser";

export default function Component(){
  const sendFormEvent = async () => {
    await form(
      "0c0910e5-5197-4dcf-8993-677e70bcb531",
      "VIEWED",
      "ac4109f5-9831-4abef-8005-647c70bfba01"
    );

    console.log("Sent FORM event.");
  };

  return (
    <div>
      <button onClick={sendFormEvent}>send FORM event</button>
    </div>
  );
};


If you have suggestions for improving this article, let us know!