Skip to main content
Table of contents

Introduction

Welcome! This document will explain integrating with Commerce Grid's App SDK (Android) solution.

App SDK (Android) allows you to monetize your mobile apps by accessing Criteo’s unique demand with a fast, lightweight, and flexible integration. Choose our App Bidding SDK or use our adapter for your mediation provider. Pick the method that applies to you and follow the below guide to start the integration.

Criteo Publisher SDK is open source and available on GitHub.

Requirements
  • Target Android API level 16 or higher

App Bidding Overview

What Is App Bidding

App Bidding allows App Developers to build a transparent and fair auction for their ad inventory by offering every ad opportunity to multiple demand partners in real-time. In-app bidding, each demand partner can compete fairly and win an impression based on the highest bid.

Why is App Bidding beneficial for App Developers?
  • App Bidding provides many benefits to App Developers:

  • Optimize revenues by getting the highest CPM for each ad opportunity

  • Provides complete transparency on the value of your ad inventory

  • Requires less manual maintenance and fewer resources

Import Publisher SDK via Maven

Make sure that mavenCentral() repository is already declared in your project-level build.gradle:

allprojects { repositories { google() mavenCentral() } }

Then, in your app's build.gradle, add the following line to the "dependencies" section to import Criteo SDK and its dependencies:

dependencies { implementation 'com.criteo.publisher:criteo-publisher-sdk:4.4.0' }

Criteo SDK uses Java 8 language features; add the following to your app's build.gradle:

android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }

Once done, save the file and perform a Gradle sync.

Importing Play Services

Criteo SDK requires play-services-ads-identifier and play-services-base package from Google. Make sure that you have the following dependencies in your app's build.gradle file.

App Bidding with Google Ad Manager

This guide explains integrating Commerce Grid's App solution with your Android app with Google Ad Manager.

Prerequisites

SDK Initialization

SDK Initialization

Initialize Criteo SDK in your Application class by using Criteo.Builder() method. This needs to be done only once. Criteo.Builder() method takes 3 parameters:

Parameter

Type

Description

application

Application

Application Object

criteoPublisherId

String

Your Criteo Publisher ID.
Contact your Criteo representative to get your Criteo Publisher ID.

inventoryGroupId

string

Id of your Commerce Grid Inventory Group (aka. publisher id).
Contact your technical account manager to get your Commerce Grid Inventory Group Ids.

If mapping ad units in Commerce Grid, use adUnits() method on the builder and pass List<AdUnit> object to initialize all ad units that Criteo will monetize, passing the ad unit IDs defined in Commerce Grid. Contact your technical account manager to get your ad unit IDs.

Banner - Load Criteo Bids

Load Criteo bids using loadBid() method that takes 2 parameters:

Parameter

Type

Description

adUnit

BannerAdUnit

BannerAdUnit object for this request

bidResponseListener

BidResponseListener

A listener object that will be executed when a response is received or timed out.

Banner - Set Criteo bids on AdManagerAdRequest.Builder object

On the BidResponseListener#onResponse() callback, check if the Bid object is not null, then call enrichAdObjectWithBid() to set the bid on your AdManagerAdRequest.Builder object.

Parameter

Type

Description

builder

AdManagerAdRequest.Builder

Ad Manager Request Builder object

bid

Bid

Bid object returned by the onResponse callback

Then, you can call loadAd() on your AdManagerAdView object.

Interstitial - Load Criteo Bids

Load Criteo bids using loadBid() method that takes 2 parameters:

Parameter

Type

Description

adUnit

InterstitialAdUnit

InterstitialAdUnit object for this request

bidResponseListener

BidResponseListener

A listener object that will be executed when a response is received, or timed out.

Interstitial - Set Criteo bids on AdManagerAdRequest.Builder object

On the BidResponseListener#onResponse() callback, check if the Bid object is not null, then call enrichAdObjectWithBid() to set the bid on your AdManagerAdRequest.Builder object.

Parameter

Type

Description

builder

AdManagerAdRequest.Builder

Ad Manager Request Builder object

bid

Bid

Bid object returned by the onResponse callback

Then, you can call loadAd() on your AdManagerInterstitialAd object.

Rewarded - Load Criteo Bids

Load Criteo bids using loadBid() method that takes 2 parameters:

Parameter

Type

Description

adUnit

RewardedAdUnit

RewardedAdUnit object for this request

bidResponseListener

BidResponseListener

A listener object that will be executed when a response is received, or timed out.

Rewarded - Set Criteo bids on AdManagerAdRequest.Builder object

On the BidResponseListener#onResponse() callback, check if the Bid object is not null, then call enrichAdObjectWithBid() to set the bid on your AdManagerAdRequest.Builder object.

Parameter

Type

Description

builder

AdManagerAdRequest.Builder

Ad Manager Request Builder object

bid

Bid

Bid object returned by the onResponse callback

Then, you can call load() on RewardedAd class.

Ad Server Setup - Keywords

Commerce Grid's App solution works best with high-density price granularity line item setup. You will need to create the first line item as a base template and duplicate the line item for all other price granularity. Please contact your Criteo representative for an alternative automated solution.

Keywords

Go to Inventory > Key-values and click on New Key to create 3 key-values:

  • Name: crt_cpm, crt_size, and crt_format

  • Value type: Dynamic

Ad Server Setup - Order

Go to Delivery > All orders and click on New Order to create a new Order for Criteo App SDK campaign.

Ad Server Setup - First Line Item

Now, you can create the first line item. The goal is to create one dedicated line item per different CPM price bands based on this first line item.

On the next page, choose Display as Ad Type.

  • Name: Use a self-explanatory name like Criteo App SDK Line Item

  • Line Item Type: Select the priority type as agreed with your Criteo representative.

  • Expected creatives:

    • Include all Banner formats available on your page. Eg: 320x50, 300x250, 320x100

    • For Interstitials, please add all 4 sizes according to Google Ad Manager's recommendation: 320x480, 480x320, 768x1024, and 1024x768

Ad Server Setup - Targeting

Below the list of sizes, click on Show Creative Details, and on the Creative Targeting section, select Add new targeting. As of Criteo SDK v3.6.0, creative targeting is required for each Banner size.

On the popup shown, write a name for the targeting, for example Criteo Targeting 320x50, and on the Custom targeting section, select crt_size with the expected banner size as the value.

Make sure to add Creative Targeting for all of your Banner sizes, and leave Interstitial sizes without targeting.

  • Delivery settings:

    • Rate: For our line item template, we'll use 0.01.

    • Type: CPM

Select the inventory for the campaign and add a Custom Targeting crt_cpm with the same value that we put in the Rate field, i.e. 0.01.

Select the AND button to add a second key value crt_format. Select is none of and enter video. This ensures the line item will not get called to deliver on video impressions.

Finally, hit Save and follow the creative steps below.

Ad Server Setup - Creative

On the popup shown, write a name for the targeting, for example Criteo Targeting 320x50, and on the Custom targeting section, select crt_size with the expected banner size as the value.

Make sure to add Creative Targeting for all of your Banner sizes and leave Interstitial sizes without targeting.

  • Delivery settings:

    • Rate: For our line item template, we'll use 0.01.

    • Type: CPM

Select the inventory for the campaign and add a Custom targeting crt_cpm with the same value that we put in the Rate field, i.e. 0.01.

Select the AND button to add a second key-value crt_format. Select is none of and enter video. This ensures the line item will not get called to deliver on video impressions.

Finally, hit Save and follow the creative steps below.

Sample

See sample implementation of Criteo App Bidding with Google Ad Manager in GitHub.

Testing

This guide explains how to get test ads for your Criteo integration and to get ready to publish your app in the store.

Troubleshooting Logs

Enable troubleshooting logs during initialization to get verbose logs from Criteo SDK by calling. debugLogsEnabled(true).

Test Ad Unit IDs

The easiest way to enable testing and get test banners is to use the Test Ad Unit IDs on your Criteo Ad Unit definition. All Ad Server codes and configurations are to be kept unchanged.

These Test Ad Unit IDs are not associated with your account. Be sure to replace the Ad Unit ID with your own Ad Unit ID after testing is completed.

Format

Test Ad Unit ID

Banner

30s6zt3ayypfyemwjvmp

Interstitial

6yws53jyfjgoq1ghnuqb

Native

190tsfngohsvfkh3hmkm

In-Banner Video

mf2v6pikq5vqdjdtfo3j

For App Bidding integrations, Test Ad Unit IDs returns a bid in US Dollar (USD) by default. If your Ad Server uses a different currency, you can append the expected 3-digit currency code behind the Test Ad Unit ID, separated by a dash -. For example, you can use 30s6zt3ayypfyemwjvmp-JPY for Banner Test Ad Unit ID that returns a bid in Japanese Yen.

Trust Custom CAs

Starting from Android Nougat (API level 24) and above, Android no longer trusts user or admin-added Certificate Authorities (CAs) for secure connections by default. To facilitate debugging with proxies, you may need to add the following security configuration to trust custom CAs. The CAs will only be trusted while your app is marked as debuggable and not on your release app.

Add the following code as res/xml/network_security_config.xml in your project:

<network-security-config><debug-overrides><trust-anchors><!-- Trust user added CAs while debuggable only --><certificatessrc="user" /></trust-anchors></debug-overrides></network-security-config>

And finally, add it to your application manifest:

<application...android:networkSecurityConfig="@xml/network_security_config"> ... </application>