Send a list of events using connectif.managed.sendEvents

The function "connectif.managed.sendEvents" is used to send a list of events to Connectif, along with any additional information that may be present on the page. Thanks to this function, it is possible to notify all types of events via JavaScript without the need to implement tags

  

This article is part of the guide to creating a custom integration.
If your integration is done through a module, this function will be inserted into your eCommerce automatically.

 

How to Use It

The function "connectif.managed.sendEvents" automatically sends the following data:

  

This function can optionally receive an array of "event" objects. If no event is specified, the data from the previous list will be sent to Connectif without any specific event. This can be useful to resynchronize the shopping cart or email without requiring a full page reload.

Requirements

It is important to use this function when Connectif has been initialized. 

const isConnectifInitialized = window.connectif?.managed?.isInitialized();

If it is not initialized, it will be necessary to wait for the event "connectif.managed.initialized".

Below is an example of how to send events while ensuring that Connectif is initialized:

function trackPageVisit() {
window.connectif.managed.sendEvents([{ type: 'page-visit' }]);
}

if (window.connectif &&
window.connectif.managed &&
window.connectif.managed.isInitialized()) {
trackPageVisit();
} else {
document.addEventListener("connectif.managed.initialized", function onConnectifInitialized() {
trackPageVisit();
},
{ once: true });
}

 

Sending "options" Object Information

The function can also optionally receive a second object "options", which may contain any of the following fields:

Name Required Type Description
options.onResponded No function Callback that will be triggered once the events have been sent to Connectif.
options.cart No object

Specifies the Shopping Cart object to be sent to Connectif (instead of retrieving the cart from the "Current shopping cart status" Tag).
Learn more at Notify cart information.

options.entityInfo No object

Specifies the Contact information object to be sent to Connectif (instead of retrieving it from the "Contact Information" Tag).
Learn more at Notify contact information.

options.pageInfo No object

Specifies the object containing page information that enriches the "page visited" event (instead of retrieving it from the page metadata and the "Page Category" Tag or "Page Tag" Tag).
Learn more at Notify page visited event.

  

After receiving a response from Connectif, the function will trigger the actions that may have been determined by Workflow flows, such as displaying inline content, a popup, etc.

 

Examples

Below, you can see how to use this function to track different events:

 

 

Congratulations!
You have reached the end of the lesson.

  

Do you still have unresolved questions?
Remember that our Connectif specialists are available to assist you. To contact them, simply open a support ticket by clicking on the blue “Help” button on your dashboard.


Keep learning!

To make the most of your Connectif account, we recommend continuing with the following articles:

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