Sending a form via AJAX to Connectif

The AJAX form submission event is used to synchronize integrated forms in Connectif and send the "submit" notification to the tool via AJAX.

  

This article is part of the guide to creating a custom integration.
If your integration is via a module, this event will be automatically inserted in your ecommerce platform.

 

How to use it

The AJAX "submit" event uses Connectif's JavaScript to send the form submission data via the sendEvents method, making the following call to Connectif:

connectif.managed.sendEvents(events, options)

 

Example

The notification will look like this:

connectif.managed.sendEvents(
    [
        {
            type: 'form-submitted',
            formId: 'ID_DEL_FORMULARIO_INTEGRADO_DE_CONNECTIF',
            primaryKeyField: 'mi_campo_email',
            payload: {
                mi_campo_email: 'test@example.org',
                mi_campo1: 1234,
                nombre: 'Test',
                campo2: 'Esto es una prueba'
            }
        }
    ]
)
  

If it is a registration form (which requests an email address), you’ll need to include the field "primaryKeyField". Its value will be the name of the field in the payload, which will contain the email that is sending the form. If the form is not a registration form, it is not necessary to indicate in the "primaryKeyField" field.

 

 

Congratulations!
You’ve reached the end of the tutorial.

  

Do you have questions?
Don’t forget, our Connectif specialists are here to help you. To contact them, just open a Support ticket by clicking the blue “Help” button on your dashboard.


TROUBLESHOOTING

What happens if the form is not detected by Connectif? There are some cases where Connectif's Integrated Forms tool cannot detect forms on your website, for example:

  • The form is on a page that requires authentication.
  • The form is built dynamically via JavaScript.

In these cases, we recommend creating a custom integration event to receive data in Connectif.

Env_o_de_un_formulario_por_AJAX_a_Connectif_-_1.png

 

  • Assign a name and set the fields to be sent by clicking  Add new field.

Env_o_de_un_formulario_por_AJAX_a_Connectif_-_2.png

 

  • Click  Save and return to the event list of your custom integration, where you will find the identifier of the newly created event:

Env_o_de_un_formulario_por_AJAX_a_Connectif_-_3.png

 

  • Copy this identifier to use it in the "eventId" field of the following code example to notify Connectif of this event:
connectif.managed.sendEvents(
    [
        {
            type: 'custom',
            eventId: 'ID_DEL_EVENTO_PERSONALIZADO_DE_RECEPCIÓN',
            payload: {
                mi_campo_email: 'test@example.org',
                mi_campo1: 1234,
                nombre: 'Test',
                campo2: 'Esto es una prueba'
            }
        }
    ]
)
 

In this case it is not necessary to indicate a "primaryKeyField" within the event, since the primary key field is set in the "mi_campo_email" field of the custom event.

 


Keep learning!

To make the most of your Connectif account, we recommend reading these articles next:

Was this article helpful?
0 out of 0 found this helpful