Documentation Integration API Reference Android SDK SwedTrack Attribution Web SDK Publishers Advertisers Log in Get Started
SwedTrack · Android

Integrate the SDK in six steps.

Drop the Kotlin module into your project, initialize once, request consent, fire events, and configure the bridge URL — that's it.

Kotlin · minSdk 21JDK 17
Step 1

Download the SDK module.

⬇ Download swedtrack-android.zip

settings.gradle
include ':swedtrack-sdk-android'
app/build.gradle
dependencies {
  implementation project(':swedtrack-sdk-android')
}
Step 2

Add permissions.

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
Step 3

Initialize in your Application class.

MyApp.kt
import com.adswedmedia.swedtrack.SwedTrack

class MyApp : Application() {
  override fun onCreate() {
    super.onCreate()
    SwedTrack.init(
      context     = this,
      appToken    = "swt_YOUR_TOKEN",
      appSecret   = BuildConfig.SWEDTRACK_SECRET,
      environment = SwedTrack.Environment.PRODUCTION
    )
  }
}
Never hard-code the secret. Read it from BuildConfig or a secrets file outside source control.
Step 4

Get user consent.

Without consent the SDK is a no-op — no data is collected, no network requests are made.

after consent dialog
SwedTrack.setUserConsent(granted = true)
Step 5

Track events.

Event tokens look like evt_29124087 — copy them from the Events tab on your app's detail page. Do not use the human name (purchase, level_5) — the SDK needs the token.

track events
// Simple event — uses the token shown in the Events tab
SwedTrack.trackEvent("evt_29124087")

// Revenue event — for in-app purchases
SwedTrack.trackRevenue("evt_29124087", amount = 4.99, currency = "USD")

// Custom data attached to the event (sent as JSON)
SwedTrack.trackEvent("evt_60625c0f", mapOf("level" to 5))
Step 6 — Critical

Wire the bridge: paste your tracking link into your ManualOffer.

This is the step that turns installs into publisher payouts. The SDK by itself only tracks data. The bridge is what tells AdswedMedia to credit the publisher who sent the user.

In your campaign / ManualOffer config in AdswedMedia, paste your SwedTrack tracking link as the destination URL, with the [[userId]] macro appended as the user_id query parameter:

destination URL
https://pro.adswedmedia.com/t/YOUR_LINK_TOKEN?user_id=[[userId]]

AdswedMedia replaces [[userId]] with each publisher's unique ManualOfferLog.token at click time. SwedTrack captures it on the click row. When the install fires, the bridge uses that token to credit the right publisher with the bid you configured on the ManualOffer.

How to test it works: click the offer in a publisher's offerwall, install your app, fire an event. Then check the publisher's claim history — you should see a new row with status 1 (paid or pending depending on auto-pay). If nothing appears, check the SwedTrack admin panel's Bridge log card for the failure reason.
If you forget Step 6: installs and events will still be tracked, but every install will be marked organic (no publisher to credit) and no publisher will ever be paid. The bridge logs moflog_not_found for every install — visible in the admin Bridge log card.
Optional

Custom HTTP integration (no Kotlin SDK).

If you need to integrate from another platform (iOS, Unity, server-side), implement the HTTP protocol directly. Every request to /sdk/v1/install and /sdk/v1/event must be HMAC-signed with your app_secret.

FieldRequiredDescription
app_tokenyesThe 16-char swt_* token from your app's SDK tab
gaid / idfainstallLowercase Google Advertising ID or Apple IDFA
install_ideventReturned by /install — store and re-send on each event
event_tokeneventThe 12-char evt_* token from the Events tab
nonceyesUnique per request, 8–40 chars. Replay-protected for 30 minutes.
timestampyesUnix seconds. Must be within ±10 minutes of server time.
signatureyesHMAC-SHA256 as described below (hex, lowercase).

How to compute signature:

pseudo-code
// 1) Take all payload fields EXCEPT signature/nonce/timestamp
// 2) Coerce values: null → "", arrays → json_encode, else → toString
// 3) Sort keys alphabetically
// 4) Build x-www-form-urlencoded body of those sorted pairs
// 5) Append "|{nonce}|{timestamp}" to the body
// 6) HMAC-SHA256, key = your app_secret as UTF-8 bytes
// 7) Hex-encode (lowercase) — that's the signature

canonical = sorted_form_query(payload_minus_sig_nonce_ts) + "|" + nonce + "|" + timestamp
signature = hmac_sha256(canonical, app_secret_string).hex().lower()
The app_secret is a 64-char hex string. Use the literal hex string as the HMAC key — do not hex-decode it. Both server and SDK sign with the UTF-8 bytes of that string.

View My Apps