Connectif JavaScript initializes by default after loading in the page. In some cases, you may want to control when the script performs this process.
This article explains how to initialize Connectif JavaScript.
STEP 1. JavaScript call
- Make the following call to initialize Connectif JavaScript..
initializeConnectif(connectifConfiguration);
- The initializeConnectif function will launch the connectif.managed.initialized event at the end of the initialization process.
- From then on you will be able to use all the functions of window.connectif.managed.
document.addEventListener('connectif.managed.initialized', function onConnectifInitialized() {
console.log('Connectif is initialized');
// now I can start tracking events
connectif.managed.sendEvents([{ type: 'page-visit' }]);
});
1.1. InitializeConnectif Function Definition
(This section explains how to avoid calling the initializeConnectif function when it is not already defined in the global variables).
- To initialize Connectif JavaScript, use the connectif.loaded event.
document.addEventListener('connectif.loaded', function onConnectifLoaded() {
console.log('Connectif is loaded');
// now I can call initializeConnectif
initializeConnectif(connectifConfiguration);
});
Keep learning!
To make the most of your Connectif account, we recommend reading these articles next:
- Sending a list of events with connectif.managed.sendEvents, to continue the custom integration process using Connectif JavaScript.
- Guide to creating a custom integration, to discover the next steps in your integration.
- Checking your website integration settings in Connectif, to define the authorized domains and script behavior.
- Configuring the ecommerce integration, to configure the synchronization and verification of your eCommerce products.