To start the Adjust SDK, you need to initialize it with a configuration table containing your app token and the environment your application will run in.
Instantiate your config table
local adjust = require "plugin.adjust"
adjust.initSdk({ appToken = "YourAppToken", environment = "SANDBOX"})
Replace YourAppToken
with your actual app token. You can find this token in your Adjust dashboard.
You must set the environment to one of the following values, depending on your build type:
SANDBOXPRODUCTION
Important: Use SANDBOX
only for development and testing builds. Switch to PRODUCTION
before publishing your app. You can change it back to SANDBOX
whenever you resume development or testing. This setting helps Adjust distinguish between test traffic and real user data. Keep it accurate at all times.
Read-only configuration
Some configuration options must be set before initializing the SDK and cannot be changed while the SDK is running. These options go inside the config table passed to initSdk
method.
Set your logging level
logLevel
You can control how much information the Adjust SDK logs by setting the logLevel
key:
Log level | Description |
---|---|
VERBOSE | Enable all logging |
DEBUG | Enable debug logging |
INFO | Only show info level logs (default option) |
WARN | Disable info logging |
ERROR | Disable warning level logging and below |
ASSERT | Disable error level logging and below |
SUPPRESS | Suppress all logging |
local adjust = require "plugin.adjust"
adjust.initSdk({ appToken = "YourAppToken", environment = "SANDBOX", logLevel = "VERBOSE"})
Set external device identifier
externalDeviceId
An external device identifier is a custom UNIQUE value that you can assign to a device or user. It helps you recognize users across sessions and platforms. It can also help you deduplicate installs so that a user isn’t counted as a duplicate new install. Contact your Adjust representative to get started with external device IDs.
You can use an external device ID as a custom identifier for a device. This helps you maintain continuity with your other systems. Assign your external device ID to the externalDeviceId
key in your config table.
externalDeviceId
(string
): Your external device identifier. This value is case sensitive. If you have imported external device IDs, make sure the value you pass matches the imported value.
local adjust = require "plugin.adjust"
adjust.initSdk({ appToken = "YourAppToken", environment = "SANDBOX", logLevel = "VERBOSE", externalDeviceId = "unique-id-for-user"})
If you want to use the external device ID in your business analytics, you can pass it as a session callback parameter.
You can import existing external device IDs into Adjust. This ensures that the Adjust servers match future data to your existing device records. Contact your Adjust representative for more information.
Set default link token
You can configure a default link token if your app is preinstalled on a device. When a user opens the preinstalled app for the first time, the install is attributed to the default link token. Assign your default link token to the defaultTracker
key in your config table.
defaultTracker
(string
): The Adjust link token you want to record preinstalled installs against.
local adjust = require "plugin.adjust"
adjust.initSdk({ appToken = "YourAppToken", environment = "SANDBOX", logLevel = "VERBOSE", defaultTracker = "abc123"})
Enable cost data sending
isCostDataInAttributionEnabled
By default, the Adjust SDK doesn’t send cost data as part of a user’s attribution. You can configure the SDK to send this data by enabling cost data sending. To enable cost data sending, assign a true
value to the isCostDataInAttributionEnabled
key in your config table.
isCostDataInAttributionEnabled
(boolean
): set totrue
to enable cost data sending.
Cost data is accessible in the user’s attribution information.
local adjust = require "plugin.adjust"
adjust.initSdk({ appToken = "YourAppToken", environment = "SANDBOX", logLevel = "VERBOSE", isCostDataInAttributionEnabled = true})
Enable background recording
isSendingInBackgroundEnabled
By default, the Adjust SDK pauses the sending of requests when your app is running in the background. You can configure the SDK to send requests in the background by enabling background recording. To enable background recording, assign a true
value to the isSendingInBackgroundEnabled
key in your config table.
isSendingInBackgroundEnabled
(boolean
): Set totrue
to enable background sending.
local adjust = require "plugin.adjust"
adjust.initSdk({ appToken = "YourAppToken", environment = "SANDBOX", logLevel = "VERBOSE", isSendingInBackgroundEnabled = true})
Dynamic configuration
Dynamic configuration options can be changed during the SDK’s lifecycle in response to user actions or other events.
Activate offline mode
function switchToOfflineMode()
The Adjust SDK normally sends event and session data to Adjust’s servers in real time. In offline mode, the SDK pauses sending data and stores it locally on the device. The data is sent to the servers once you disable offline mode.
To enable offline mode, call the switchToOfflineMode
method.
adjust.switchToOfflineMode()
Deactivate offline mode
function switchBackToOnlineMode()
You can re-enable the SDK by calling the switchBackToOnlineMode
method.
adjust.switchBackToOnlineMode()
Set push tokens
function setPushToken(token)
Push tokens are used for Audiences and client callbacks. They’re also required for Uninstall and reinstall measurement.
You should pass the push notification token to Adjust each time they obtain it, and again whenever the token is updated on the device by calling setPushToken
method and pass:
token
(string
): Your push notification token.
local adjust = require "plugin.adjust"
adjust.setPushToken("push-notifications-token")
Disable the SDK
function disable()
The Adjust SDK runs by default while your app is open. To stop sending data to Adjust, call the disable
method. When the SDK is disabled, no information is recorded or sent, and any Adjust methods you call during this time won’t track data.
adjust.disable()
Enable the SDK
function enable()
If you’ve disabled the SDK and want to re-enable it, call:
adjust.enable()
Check enabled status
function isEnabled(callback)
You can check whether the Adjust SDK is currently enabled. This method returns a boolean
value (true
if enabled, false
if disabled) through the provided callback:
adjust.isEnabled(function(event) print("[Adjust]: Is SDK enabled = " .. event.message)end)