The Adjust Web SDK enables you to record attribution, events, and other data in your web app. This guide shows you how to integrate the SDK with your app.
1. Add the SDK to your project
To get started, add the SDK to your web app. The Adjust SDK works in both CommonJS and AMD (Asynchronous Module Definition) environments. You can access it through the global Adjust namespace when loaded through a CDN (Content Delivery Network).
Using a CDN
When loading the SDK through a CDN, you should use a minified version in your production build.
To load a specific version, add it to the CDN target, like this: https://cdn.adjust.com/adjust-5.7.0.min.js.
To load the latest version, use the adjust-latest package, like this: https://cdn.adjust.com/adjust-latest.min.js. This package updates automatically so you don’t need to change the target file.
To load the SDK through a CDN, add the following snippet inside your web app’s <head> element:
The Adjust SDK loads on each page and initiates once per page load.
Subresource Integrity
You want to use Subresource Integrity checks to mitigate XSS (Cross-Site Scripting) attacks. To validate the package before running it, use the following call (note the additional crossOrigin, integrity, and encoded hash):
Using npm
The Adjust SDK is also available on npm. To add the package to your project, use your preferred package manager:
Once you’ve installed the SDK, you need to initialize it. To do this, call the initSdk method. This method has arguments that you can use to customize how the SDK works in your app.
To initialize the SDK, you must add the following arguments to your initSdk call: