initialized

From Genesys Documentation
Jump to: navigation, search
This topic is part of the manual Journey JavaScript SDK for version Current of Altocloud.

Learn how to use the initialized method to be notified when the Journey JavaScript SDK has fully initialized.

Related pages:

Description

Use the initialized method to be notified when the Journey JavaScript SDK has fully initialized. This may be useful in situations where tracking data from the Journey JavaScript SDK is required, but because SDK initialization takes place after the page has loaded, tracking has not yet begun.

For example, some businesses require GDPR consent before they begin tracking user activity. In this case, a business may present a GDPR consent dialog box to a user when the user arrives at the webpage. Until the user has agreed to allow tracking, the Journey JavaScript SDK remains in an uninitialized state, and calls to SDK methods, such as the api.session methods, will fail.

After the user provides their consent, the SDK may be initialized and can begin tracking visitor activity. Once initialized, callbacks registered using the initialized method will be invoked and can begin to use the Journey JavaScript SDK's other methods.

Signature

ac('initialized', <function> eventHandler);

Example

ac('initialized', () => {
  console.log('Tracking SDK initialized');
  ac('api.session.getData', (session) => {
    console.log('Session data', session);
  });
});
Retrieved from "https://all.docs.genesys.com/ATC/Current/SDK/initialized (2020-08-08 06:05:24)"