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

<script>
(function(G,m,s,g,h,t){G.gsght=G.gsght||function(){
(G.gsght.q=G.gsght.q||[]).push(arguments)},G.gsght.q=[],G.gsght.h=1*new Date();
h=m.createElement(s),t=m.getElementsByTagName(s)[0];h.async=1;h.src=g;t.parentNode.insertBefore(h,t)
})(window,document,'script','https://cdn.gsght.com/sdk.js');
  
gsght('init', 'GS-XXXXXX')
</script>

The full method signature for initialize is the following:

gsght('init', '{web_api_key}', '[{platform}]', '[{instance_name}]')
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

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', {...})