initialized

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

Learn how to use the initialized method to receive notification when the Journey JavaScript SDK has initialized fully.

Related pages:

Description

Use the initialized method to receive notification when the Journey JavaScript SDK initializes fully. This information is useful in situations that require tracking data from the Journey JavaScript SDK, but because SDK initialization takes place after the page loads, tracking has not begun.

For example, some businesses require GDPR consent before they begin tracking visitor activity. A business can present a GDPR consent confirmation request to a visitor when the visitor arrives at the webpage. Until the visitor agrees to allow tracking, the Journey JavaScript SDK remains in an uninitialized state, and calls to SDK methods, such as the api.session methods, fail.

After the visitor provides their consent, the SDK initializes and can begin tracking visitor activity. Once initialized, callbacks registered using the initialized method are 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 (2021-01-27 16:27:03)"