> ## Documentation Index
> Fetch the complete documentation index at: https://developers.criteo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Adjust In-App Events [Android]

> Implement Criteo in-app events for Android using the Adjust SDK.

## Overview

This document provides detailed information on the following implementation steps related to the source code of the app (if required):

* Recommended events and parameters
* Deep link implementation
* Testing requirements

For general integration steps, check [Criteo Integration With Adjust](/mobile-integrations/docs/adjust-criteo-integration).

## In-App Events Implementation

### View Home

The viewHome event is automatically sent once Criteo has been activated on the app. It is triggered for each new user session.

### App Deeplink

The AppDeeplink event should be triggered every time the app is opened with a deeplink. For each activity that accepts deep links, find the `onCreate` method and add the following call:

```java theme={null}
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    Uri data = intent.getData();

    AdjustEvent event = new AdjustEvent("{deeplinkEventToken}");
    event.addPartnerParameter("criteo_deeplink", data.toString());
    Adjust.trackEvent(event);
    //...
}
```

### View Listing

The viewListing event should be triggered on screens displaying product lists, like category or search results screens. To allow our platform to identify the type of products the user is interested in, you must include the IDs of the top three products displayed in the list, which should match those provided in the catalog feed.

```java theme={null}
AdjustEvent event = new AdjustEvent("{viewListingEventToken}");
List<String> productIds = Arrays.asList("productId1", "productId2", "productId3");
event.addPartnerParameter("products", productIds.toString());
Adjust.trackEvent(event);
```

### View Product

The viewProduct event should be triggered on all product-details screens. You must include the ID of the product detailed on the screen, which must be the same one provided in the catalog feed.

```java theme={null}
AdjustEvent event = new AdjustEvent("{viewProductEventToken}");
event.addPartnerParameter("product", "productId");
Adjust.trackEvent(event);
```

### View Basket

The viewBasket event should be triggered on the basket-details screens. You must include the IDs, unit prices, and quantities of the products available in the basket.

```java theme={null}
AdjustEvent event = new AdjustEvent("{cartEventToken}");
List<String> productIds = Arrays.asList("productId1","productId2","productId3");
List<String> productPrice = Arrays.asList(12.0, 25.0, 2.0);
List<String> productQuantity = Arrays.asList(1, 2, 3);
event.addPartnerParameter("productids", productIds.toString());
event.addPartnerParameter("productPrice", productPrice.toString());
event.addPartnerParameter("productQuantity", productQuantity.toString());
Adjust.trackEvent(event);
```

### Track Transaction

The trackTransaction event should be triggered on order confirmation screens after checkout. You must include a unique transaction ID as well as the IDs, unit prices, and quantities of the products contained in the transaction.

```java theme={null}
AdjustEvent event = new AdjustEvent("{transactionConfirmedEventToken}");
List<String> productIds = Arrays.asList("productId1","productId2","productId3");
List<String> productPrice = Arrays.asList(12.0, 25.0, 2.0);
List<String> productQuantity = Arrays.asList(1, 2, 3);
event.addPartnerParameter("productids", productIds.toString());
event.addPartnerParameter("productPrice", productPrice.toString());
event.addPartnerParameter("productQuantity", productQuantity.toString());
event.addPartnerParameter("transactionId", "abc123");
event.addPartnerParameter("currency", "AUD");
event.addPartnerParameter("setRevenue", "68.0");
Adjust.trackEvent(event);
```

### Dates for Travel

It's possible to attach check-in and check-out dates to every Criteo event with the parameter keys `din` & `dout`. The format of the dates is `"yyyy-mm-dd"` and it has to be set every time a user enters new search dates. For example:

```java theme={null}
event.addPartnerParameter("din", "2020-01-01");
event.addPartnerParameter("dout", "2020-01-07");
```

The dates will be sent with every Criteo event for the duration of the application lifecycle, so they must be set again when the app is re-launched. The search dates can be removed by setting the parameter keys `din` & `dout` to `null`.

<Note>
  For one-way flight, you can skip the check-out parameter.
</Note>

### Hashed Email for Cross-Device Targeting

Clients have the option of sending Criteo the email address of app users when available. This will enable the cross-device Criteo targeting feature.

For instance, if the email is "[*j.doe@gmail.com*](mailto:j.doe@gmail.com)", it can be sent in the format of [SHA-256](https://en.wikipedia.org/wiki/SHA-2) (preferred) or [MD5](https://en.wikipedia.org/wiki/MD5) hashed strings in the events as below:

SHA-256:

```java theme={null}
event.addPartnerParameter("criteo_email_hash_sha256", "3ce6f3866c13320081cd44f40402527b94f4c2ef24ea1ee163e83650b8f04d01");
```

MD5:

```java theme={null}
event.addPartnerParameter("criteo_email_hash_md5", "8115b7da7fff37aeaec18779411a1042");
```

The hashed email will be sent with every Criteo event for the duration of the application lifecycle, so it must be set again when the app is relaunched. The hashed email can be removed by setting the value to an empty string:

```java theme={null}
event.addPartnerParameter("criteo_email_hash", "");
```

Following are the steps to generate a hashed email address for Criteo:

* Convert all characters to lower case
* Remove any blank spaces
* Convert to UTF-8
* Hash using SHA-256 or MD5 algorithm
* Email addresses need to be hashed before setting them in the event parameter. You can use existing libraries in Java/Kotlin or create your own function for it.

### Customer ID

A Customer ID can be provided in all events. If the user is logged in to the advertiser's app, the user ID should be passed.

<Note>
  User ID is an optional parameter and should be left as an empty string if the user is logged out or the User ID is unavailable.
</Note>

Customer ID can be any string, as long as it does not contain any Personally Identifiable Information.

```java theme={null}
event.addPartnerParameter("customer_id", "12323dsvhdsb23");
```

## Enabling Reattribution via Deeplink

### Adjust SDK v4.11.4+

Adjust enables you to run re-engagement campaigns with usage of deep links. If you are using the Adjust SDK v4.11.4 and above, this feature is enabled within the SDK. Once you have received deep link content information in your app, add a call to the `appWillOpenUrl` method. By making this call, the Adjust SDK will try to find if there is any new attribution info inside of the deep link and if any, it will be sent to the Adjust backend.

The function `appWillOpenUrl` should be implemented as follows to support deep linking reattributions in all Android versions:

```java theme={null}
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();
    Uri data = intent.getData();
    Adjust.appWillOpenUrl(data);
}
...
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Uri data = intent.getData();
    Adjust.appWillOpenUrl(data);
}
```

For more info, check Adjust Help Center: [Reattribution using deep links](https://help.adjust.com/en/article/deep-linking-android-sdk#reattribution-deep-links)

## Testing Process

You should contact Criteo to start the testing phase as soon as the events are implemented.

<Warning>
  Please allow sufficient time (at least a week before) for testing prior to the app submission in order to ensure that the data you are sending is complete.
</Warning>

Criteo will require an app build (APK) to test the collection of events on Criteo side, so please share the same with your Criteo Contact.
