The Adjust Web SDK enables you to record attribution, events, and more in your web app. This guide shows you how to integrate the Adjust SDK with your app.
1. Add the SDK to your project
To get started, you need to add the SDK to your web app. The Adjust SDK works in both CommonJS and AMD (Asynchronous Module Definition) environments and can be accessed through a 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. You can specify a version by adding it to the CDN target like this: https://cdn.adjust.com/adjust-5.6.0.min.js
. You can get the latest version by targeting 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 between your web app’s <head>
tags:
The Adjust SDK loads on each page and initiates once per page load.
Subresource Integrity
If you want to use Subresource Integrity checks to mitigate against XSS (Cross-Site Scripting) attacks, you can validate the package before running it by using the following call:
Using npm
The Adjust SDK is also available on npm. To add the package to your project, use your preferred package manager:
2. Initialize the SDK
Once you’ve installed the SDK, you need to initialize it. To do this, call the initSdk
method. This method takes a number of arguments that customize how the SDK works in your app.
You must add the following arguments to your initSdk
call to initialize the SDK:
appToken
(string
): Your Adjust app token.environment
(string
): The environment you want to run the SDK in. Passsandbox
to run the SDK in sandbox mode for testing. Passproduction
to run the SDK in production mode for release.