JavaScript SDK


Download and Installation

Github Repository

Use the download button below to download SDK files from Github.

Unzip the downloaded .zip and include this in your project (the files are located in the dist folder):

The above code does four main things:

  1. Creates a <script> element that starts asynchronously downloading the GameAnalytics.js JavaScript library from[VERSION].min.js (replace [VERSION] with the latest or desired version of the SDK)
  2. Initializes a global GameAnalytics function (called the GameAnalytics() command queue) that allows you to schedule commands to be run once the GameAnalytics.js library is loaded and ready to go.
  3. Adds a command to the GameAnalytics() command queue to enable info logging.
  4. Adds another command to the GameAnalytics() command queue to initialize the SDK (replace GAME_KEY and SECRET_KEY with your actual keys).

Alternative async GA snippet

While the JavaScript GA snippet described above ensures the script will be loaded and executed asynchronously on all browsers, it has the disadvantage of not allowing modern browsers to preload the script.

The alternative async GA snippet below adds support for preloading, which will provide a small performance boost on modern browsers, but can degrade to synchronous loading and execution on IE 9 and older mobile browsers that do not recognize the async script attribute. Only use this tracking snippet if your visitors primarily use modern browsers to access your site.