The init method is used to create a new instances of the Gamesight Web SDK and to configure some base settings.

You can access your Web SDK snippet from the Management page in Gamesight, under Game > In-Game Integrations as shown below.

If you do not have access to this page, please contact an Admin for your Game so they can grant you the "Game Integrator" permissions.

853

The full method signature for initialize is the following:

gsght('init', '{web_api_key}', '[{platform}]', '[{instance_name}]', '[{options}]')
ArgumentTypeExampleDescription
{web_api_key}StringGS-000000The Web API Key for this instance of the SDK. More details in the Web Measurement SDK Quick Start
{platform}String (optional)'web' (default)The platform value to use for this instance - see Identifiers for a full list of platform values
{instance_name}String (optional)'my_instance'The optional name for this instance, see the Using Named Instances below for more details
{options}Object{}Option set of additional options to pass to your instance. All values that can be set through the set can can be initialized with the options value

Using Named Instances

If you would like to have multiple instances of the Web SDK on a single page you can utilize the named instances feature. This allows you to create and reference multiple instances by a unique name so they can be managed independently. The below example shows how you can utilize named instances.

// initialize 2 named instances 
gsght('init', 'web_api_key', 'web', 'my_name')
gsght('init', 'web_api_key2', 'web', 'my_other_name')

// specify the name in the command separated by a period (.) 
gsght('my_name.set', 'user_id', [...])
gsght('my_name.send', 'event_name', {...})
gsght('my_other_name.send', 'event_name', {...})

Passing options

If you would like to pass additional options into your Web SDK instance you can do so during the initialization.

gsght('init', 'web_api_key', {
  acm_enabled: true, // Enable Automatic Click Measurement
  cookies_enabled: false, // Disable cookie storage by the Web SDK
  ga_enabled: true, // Enable the google analytics integration
  fb_enabled: true, // Enable the fb pixel integration
  root_domain: 'https://gsght.com', // Override the root domain
  warnings: true, // Enable warnings / logging from the Web SDK
})

🚧

A Note on Initializing Integrations in the 'init' Block

If you initialize the integration during the 'init' block, it's not necessary to also 'set' the integration status to true.