Adjust offers a server-to-server (S2S) interface for mobile, console, and Connected TV (CTV) apps. If you choose to implement Adjust through S2S, you need to modify your app to replicate the Adjust SDK’s functions. This guide provides step-by-step instructions for the following:
How to make the necessary updates to your app.
How to send S2S requests to Adjust.
Before you begin
Here’s what you need to do before you get started.
Enable S2S session measurement
If you’re using the S2S interface for a mobile app, Adjust needs to enable S2S session measurement for your app. Contact your Adjust representative or support@adjust.com to proceed.
Implement S2S Security to safeguard your S2S activities and prevent spoofed requests. Generate a token in your Adjust dashboard and include it in each incoming request.
Queue and persist events locally
Users may trigger important events, such as app installs or sessions, while their device is offline. To ensure accurate attribution, you must capture and store these events locally until they can be successfully transmitted to Adjust’s servers.
To implement a local event queue with persistence:
Create a queue to store activities when they occur.
For each activity, include a created_at_unix timestamp in seconds (for example: 1484085154) representing when the event occurred on the device.
Save this queue to local storage (for example: SQLite database or files) to persist across app restarts.
Attempt to send activities to Adjust’s servers when the queue is non-empty and the device is online.
Remove activities from the queue only after successful transmission.
This approach helps mitigate data loss in the following scenarios:
Brief network interruptions (for example: 5G to WiFi handovers).
Extended periods without connectivity.
App crashes or force closes before transmission.
Without local queuing, you risk losing 10–20% of install data, which can significantly impact attribution accuracy. By implementing this queuing system, you ensure that Adjust receives a complete and accurate picture of user activity, enabling precise attribution even for events that occur offline.
Add iOS frameworks
You must link frameworks to your project to support certain iOS features. To add frameworks to your project:
Open your project in Xcode.
Select your target in the project navigator.
Go to the General tab.
Scroll to the Frameworks, Libraries, and Embedded Content section.
Select the + button.
Search for and add the frameworks that your app requires from the list below.
Framework
Description
AdSupport.framework
Required to collect IDFA. Also required to collect Limit Ad Tracking status for pre-ATT iOS versions.
AppTrackingTransparency.framework
Required to show the AppTrackingTransparency prompt and to collect IDFA on devices running iOS 14.5 and later.
AdServices.framework
Required for Adjust to attribute to Apple Search Ads campaigns.
StoreKit.framework
Required to run SKAdNetwork campaigns.
Required parameters
The following parameters are required in each S2S request.
Parameter
Description
s2s
Indicates that the request is an S2S request. Must be hardcoded to 1.
app_token
Your Adjust app token.
os_name
The name of the mobile operating system. See the list of options below.
android
android-tv
apple-tv
bada
blackberry
fire-tv
ios
linux
macos
nintendo
playstation
roku-os
server
smart-cast
steamos
symbian
tizen
unknown
webos
windows
windows-phone
xbox
Create these parameters on your server. They will be used for all S2S requests to Adjust, regardless of the device. Additional device-specific parameters will be added as needed. For simplicity, this guide demonstrates all parameter handling on the client side, though in practice, much of this will occur server-side.
// The name of the operating system running on the device
8
params[@"os_name"] =@"ios";
9
10
// Replace with your Adjust app token
11
params[@"app_token"] =@"4w565xzmb54d";
1
// Create map for params to include on all S2S requests to Adjust
2
val params =mutableMapOf<String, String>()
3
4
// Hard-coded
5
params["s2s"] ="1"
6
7
// The name of the operating system running on the device
8
params["os_name"] ="android"
9
10
// Replace with your Adjust app token
11
params["app_token"] ="4w565xzmb54d"
1
// Create map for params to include on all S2S requests to Adjust
2
Map<String, String> params =new HashMap<>();
3
4
// Hard-coded
5
params.put("s2s", "1");
6
7
// The name of the operating system running on the device
8
params.put("os_name", "android");
9
10
// Replace with your Adjust app token
11
params.put("app_token", "4w565xzmb54d");
Device IDs and tracking statuses
Every S2S request must include at least one device identifier. Due to privacy measures implemented by mobile operating systems, the advertising ID may not always be available. Therefore, you should include the advertising ID when available and always include backup identifiers.
PC and Console / CTV device IDs
For PC and Console and CTV measurement, you can pass a unique external_device_id parameter with each call to use as a device identifier. This value can be any unique string that identifies the device.
iOS device IDs
IDFA and tracking status
The ID for Advertisers (IDFA) is available only for iOS devices where users have opted to share it. Some apps collect IDFA, other apps don’t. Regardless of whether an app collects IDFA, Adjust requires the tracking status in each request. Use the code below that corresponds to your implementation.
Apps that collect IDFA
Add ATT description in Xcode.
Open your project’s Info.plist file.
In the editor, right-click on Information Property List and choose Add Row to add a key to the root.
Set the key to NSUserTrackingUsageDescription.
Set the value to a string explaining why you’re requesting tracking permission (for example: “This identifier will be used to deliver personalized ads to you.”). Be sure to review Apple’s guidelines for this text.
Implement ATT prompt and IDFA retrieval.
ATT has the following requirements:
While ATT support begins with iOS 14, user consent for IDFA retrieval is only required from iOS 14.5 onwards. Therefore, Adjust recommends targeting the ATT prompt specifically to users on iOS 14.5 and later versions.
The ATT prompt requires an active app state to display. Showing it immediately after other system prompts may fail unless you first wait for the app state to be active again.
The earliest places to show the prompt are in applicationDidBecomeActive (App Delegate) or sceneDidBecomeActive (Scene Delegate). It’s not possible to show the ATT prompt in didFinishLaunchingWithOptions (App Delegate).
The below code example meets all of these requirements.
For accurate attribution, include the IDFA in the first session request and all subsequent requests whenever it is available.
To consistently measure app activities across uninstalls and reinstalls, generate a random version 4 UUID (the “primary deduplication token”) and save it in the iOS keychain. The primary deduplication token is a backup identifier that you should generate for all devices.
The Google Play Services Advertising ID (GPS ADID) is available on Android devices with Google Play Services, provided the user hasn’t opted to delete their advertising ID.
Add the play-services-ads-identifier dependency to your app’s build.gradle file:
If your app uses R8 or ProGuard, add these rules to your proguard-rules.pro file to preserve classes and methods needed for Google Advertising ID retrieval during code optimization (create the file in your app module’s directory if it doesn’t exist):
// Retrieve the device's IP address from requests to
39
// your server
40
params["ip_address"] ="192.0.0.1"// Example value
Environment
You can specify the environment that requests are being sent in by passing an environment parameter. Requests from different environments are kept separate in Adjust to enable testing. The following values are available:
sandbox: use this while testing to keep your requests separate from your production data.
production: use this when you release your app.
If you don’t pass this parameter, the default value is production.
When using raw data exports, you can include “global callback parameters” in all your S2S requests to add custom parameters to the raw data. This is commonly used to include your internal user ID in your exported raw data.
Global callback parameters are represented as a JSON object containing string key-value pairs.
When integrating with certain partners, you may need to include “global partner parameters” in all your S2S requests. Adjust’s servers passes these parameters in all callbacks it makes to partners. This is commonly used for analytics partners that require their own proprietary user ID in the callbacks they receive.
Global partner parameters are represented as a JSON object containing string key-value pairs.
Sessions form the foundation of Adjust implementation and are the only required activity. A session typically represents an app open. Adjust’s servers log successful session requests as follows:
It records the first session for a device as an “install” activity.
It records subsequent sessions as “session” activities.
It records a “reattribution” or “reattribution reinstall” activity if reattribution criteria are satisfied.
When sending S2S session requests with the created_at_unix parameter, Adjust’s servers require this value to be at least 20 minutes later than the created_at_unix time of the last successfully logged session.
This is the response format when Adjust successfully logs the first session for the device. You can use the Adjust testing console to forget your device and test this multiple times, if needed.
Response
{
"app_token": "4w565xzmb54d",
"adid": "df6c5653080670612cd2f9766ddc0814",
"timestamp": "2024-07-09T01:31:14.373Z+0000",
"message": "Install tracked",
"ask_in": 2000
}
HTTP Status Code: 200
This is the response format when Adjust successfully logs subsequent sessions for the device.
Response
{
"app_token": "4w565xzmb54d",
"adid": "df6c5653080670612cd2f9766ddc0814",
"timestamp": "2024-07-09T02:31:14.373Z+0000",
"message": "Session tracked",
"ask_in": 5000
}
HTTP Status Code: 200
Post-install event
After you send at least one successful session request for a device, you can send post-install events. These are typically events that represent marketing goals, and that networks can use to optimize campaigns.
When using raw data exports, you can include custom “callback parameters” in specific event requests to add event-level custom data. For instance, on a purchase event, you might want to include your internal transaction ID in the raw data for that event.
Callback parameters are represented as a JSON object containing string key-value pairs.
When integrating with certain partners, you may need to include custom “partner parameters” in your event requests. Adjust’s servers will then include these parameters on the callbacks it makes to partners for relevant events. This is most commonly used to enable dynamic remarketing campaigns, typically for events like view_item, add_to_cart, and purchase.
Partner parameters are represented as a JSON object containing string key-value pairs.