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.
How to Use It
The function "connectif.managed.sendEvents" automatically sends the following data:
- Shopping cart information (data from the "Current shopping cart status" Tag).
- Current contact information (data from the "Contact Information" Tag).
- Web Push notification subscription information (more info in Web Push Features).
- Available containers for banner placement (data from the "Banner" Tag).
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). |
options.entityInfo | No | object |
Specifies the Contact information object to be sent to Connectif (instead of retrieving it from the "Contact Information" Tag). |
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). |
Examples
Below, you can see how to use this function to track different events:
- Notify page visited event.
- Notify product visited event.
- Notify purchase event.
- Notify cart information.
- Notify contact information.
- Notify search event.
- Notify newsletter subscription event.
- Notify login event.
- Notify registration event.
- Notify custom event.
Keep learning!
To make the most of your Connectif account, we recommend continuing with the following articles:
- Adding Connectif JavaScript to your website, to insert the code and start collecting information about visits to your site.
- Integration via tags, to learn about all the notifications you can send from your eCommerce to Connectif and how they work.
- Integration with Connectif via API, to synchronize contacts, products, purchases, and coupons.
- Verify eCommerce integration, to ensure that all data is synchronizing correctly in your Connectif account.