# Android SDK

### **Get started**

To start tracking using Offer18's Android SDK, you'll need to integrate the SDK into your application as a dependency.

For **Gradle** in **Kotlin,** Add dependencies in the `build.gradle.kts` file

```gradle
implementation("com.offer18:android-sdk:{VERSION}")
```

For **Gradle** in **Groovy,**  Add dependencies in the `build.gradle` file

```gradle
implementation 'com.offer18:android-sdk:{VERSION}'
```

{% hint style="warning" %}
You must replace `{VERSION}` with latest stable version of Offer18's Android SDK
{% endhint %}

Find out latest stable version of Android SDK

{% embed url="<https://central.sonatype.com/artifact/com.offer18/android-sdk>" %}

***

### Permissions

Make sure your app has permissions given below

```xml
<uses-permission android:name="android.permission.INTERNET"/>
```

***

### SDK Initialization

Import `Offer18` Class from `com.offer18.sdk` package

```java
import com.offer18.sdk.Offer18;
```

To initialize the Software Development Kit (SDK) insert the provided code snippet in your application code.

{% code fullWidth="false" %}

```java
Offer18.init(getApplicationBaseContext(), "{DOMAIN}", "{ACCOUNT_ID}","tid_key_in_referrer_url");
```

{% endcode %}

{% hint style="info" %}

* Replace `{DOMAIN}` with your tracking domain.&#x20;
* Replace `{ACCOUNT_ID}` with your Account ID.
* Replace **tid\_key\_in\_referrer\_url** With your own parameter key for tid
  {% endhint %}

***

### Track Conversions

Import `Offer18` Class from `com.offer18.sdk` package

```java
import com.offer18.sdk.Offer18;
```

To activate conversion tracking with Offer18's Android SDK, you'll need to insert a specific code snippet onto the order success page (Thank You Page) of your app.

```java
Map<String, String> args = new HashMap<>();  
args.put("o", ""); // 0000000 (Offer ID)
args.put("tid", "");  // x-xxxx-xxxxxx-xxxxxx (Click ID)
args.put("event", ""); // install
args.put("adv_sub1", ""); 
args.put("adv_sub2", "");
args.put("adv_sub3", "");
args.put("adv_sub4", "");
args.put("adv_sub5", "");
args.put("coupon", "");
args.put("sale", "");
args.put("payout", "");
Offer18.trackConversion(args);
```

***

### Track Conversion (Automatic)

Import `Offer18` Class from `com.offer18.sdk` package

```java
import com.offer18.sdk.Offer18;
```

If you prefer not to fetch Referrer details to obtain the click ID, you can utilize Offer18's Click ID key in the configuration.

#### Initialize SDK&#x20;

To initialize the Software Development Kit (SDK) insert the provided code snippet in your application code.&#x20;

```java
Offer18.init(getApplicationBaseContext(), "{DOMAIN}", "{ACCOUNT_ID}","tid_key_in_referrer_url");
```

#### Complete Conversion

```java
Map<String, String> args = new HashMap<>();  
args.put("o", ""); // Offer ID  
args.put("tid", "{REFERRER_TID}"); // Auto fill TID
args.put("event", ""); // install
args.put("adv_sub1", "");
args.put("adv_sub2", "");
args.put("adv_sub3", "");
args.put("adv_sub4", "");
args.put("adv_sub5", "");
args.put("coupon", "");
args.put("sale", "");
args.put("payout", "");
Offer18.trackConversion(args);
```

{% hint style="info" %}
The "**{REFERRER\_TID}**" will automatically retrieve the click ID from the Referrer URL and include it in the trackConversion.

* TID will be detected automatically based on key value provided during SDK initialization
* Replacement will occur when micro **{REFERRER\_TID}** is detected
* **trackConversion** will be fail if
  * No manual **tid** provided,&#x20;
  * No **tid** detected using referral url&#x20;
  * **tid** detected but no macro provided&#x20;
  * Macro provided but no **tid** or empty **tid** detected from referrer url
    {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledgebase.offer18.com/network/sdk/android-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
