Native Cross Promotion

Native ads are flexible ad units which are stored in a TDNativeAdvert variable.

NEW: SDK version 7.0.0 supports zones. Please note, this release does not currently support cross promotion ad serving. To access our cross promotion features, please use SDK version 6.4.0

1. Register a placement tag

To begin preparations for fetching a native ad, go back to your main activity where you had setup the Tapdaq SDK, and add modify it to look like this:

List<TapdaqPlacement> enabledPlacements = new ArrayList<TapdaqPlacement>();
enabledPlacements.add(TapdaqPlacement.createPlacement(Arrays.asList(CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE)), "my_native_tag"));

TapdaqConfig config = new TapdaqConfig();
config.withPlacementTagSupport(enabledPlacements.toArray(new TapdaqPlacement[enabledPlacements.size()]));

Tapdaq.getInstance().initialize(this, "<APP_ID>", "<CLIENT_KEY>", config, new TapdaqInitListener());

Note: Here we use the example of a @"my_interstitial_tag", but you can use any custom string e.g. @"my_custom_tag".

If you want to use multiple placement tags in your application, simply instantiate multiple TapdaqPlacement objects and add them to the enabledPlacements array, like so:

List<TapdaqPlacement> enabledPlacements = new ArrayList<TapdaqPlacement>();
enabledPlacements.add(TapdaqPlacement.createPlacement(Arrays.asList(CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE)), "my_native_tag"));
enabledPlacements.add(TapdaqPlacement.createPlacement(Arrays.asList(CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE)), "my_custom_tag"));

2. Override TMAdListener

Next, you will need to override the TMAdListener class to receive callbacks on native adverts. Create a new class and implement it like so:

public class NativeAdListener extends TMAdListener {

    @Override
    public void didLoad() {
        // Ready to fetch the native ad
    }

}

3. Load the native ad

To load a native ad, we recommend you load them once the Tapdaq SDK has initialised.

Go back to the TapdaqInitListener you created in the Quickstart guide, and add a call to load the native ad, like so:

public class TapdaqInitListener extends TMInitListener {

    @Override
    public void didInitialise() {
        super.didInitialise();
        // Ads may now be requested
        CreativeType creativeType = CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE);
        Tapdaq.getInstance().loadNativeAdvert(<CurrentActivity>, creativeType, "my_native_tag", new NativeAdListener());
    }

}

Here is a list of all the possible CreativeTypes.

4. Fetch the native ad

Update your NativeAdListener class you created earlier to fetch the native ad:

public class NativeAdListener extends TMAdListener {

    @Override
    public void didLoad() {
        // Ready to fetch the native ad
        CreativeType creativeType = CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE);
        TMNativeAd nativeAd = Tapdaq.getInstance().getNativeAdvert(<CurrentActivity>, creativeType, "my_native_tag", new NativeAdListener());

    }

}

It is also possible to check the native ad is loaded before fetching it, as shown below:

TMNativeAd nativeAd = null;
CreativeType creativeType = CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE);

if (Tapdaq.getInstance().isNativeAdvertReady(<CurrentActivity>, creativeType, "my_native_tag")) {
    nativeAd = Tapdaq.getInstance().getNativeAdvert(<CurrentActivity>, creativeType, "my_native_tag", new NativeAdListener());
}

You can now create a custom UI to display the TMNativeAd object.

All data used to display an ad can be retrieved via get methods on the TMNativeAd object, for example:

if (nativeAd != null) {
    String nativeAdAppName = nativeAd.getAppName();
    Bitmap nativeAdBitmap = mAd.getImage(<CurrentActivity>.this);
}

5. Sending the impression and click

The benefit of using native adverts is you have full control over the UI, but you must explicitly tell Tapdaq when an impression and click occurs.

If these methods below are not implemented, you will not see impressions and clicks in your app's performance page.

Impression

An impression should be registered each time the advert is presented to the user.

To trigger an impression, use the following:

nativeAd.triggerDisplay(<CurrentActivity>.this);

Click

A click will not only just register, but also direct the user to where the user should go after clicking the advert, this can be to the App Store, a deeplink, etc.

To trigger a click, use the following:

nativeAd.triggerClick(<CurrentActivity>.this);

Build and run your application to test the ad displays correctly.

6. Native Ad Sizes

Below are the possible creative types we support. Each ad type has a "small", "medium" or "large" sizing, this determines the size of the advert you are fetching.

If you want a square advert to appear in a small part of the screen real-estate, we would advise using CreativeType.get(NativeAspectRatio._1X1, NativeSize.SMALL), but if you want a square advert to cover the majority of the screen real-estate, you should opt for CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE).

The pixel size of each advert is relative to the pixel density of the device. A phone that has a XXHDPI screen resolution is 3 times the size of a device that has a MDPI screen resolution.

We support the following densities:

  • XXHDPI
  • XHDPI
  • HDPI
  • MDPI

If your device is greater than XXHDPI, a XXHDPI image will be served to the device. If your device is lower than MDPI, a MDPI image will be served to the device.

For more information on pixel densities in Android, see the official documentation.

Below is a table of each creative type and the largest possible pixel dimensions (the XXHDPI pixel densities) to give you a guideline of what image size to expect.

CreativeType Width (px) Height (px)
CreativeType.get(NativeAspectRatio._1X1, NativeSize.LARGE) 750 750
CreativeType.get(NativeAspectRatio._1X1, NativeSize.MEDIUM) 375 375
CreativeType.get(NativeAspectRatio._1X1, NativeSize.SMALL) 150 150
CreativeType.get(NativeAspectRatio._2X1, NativeSize.LARGE) 1800 900
CreativeType.get(NativeAspectRatio._2X1, NativeSize.MEDIUM) 900 450
CreativeType.get(NativeAspectRatio._2X1, NativeSize.SMALL) 360 180
CreativeType.get(NativeAspectRatio._1X2, NativeSize.LARGE) 900 1800
CreativeType.get(NativeAspectRatio._1X2, NativeSize.MEDIUM) 450 900
CreativeType.get(NativeAspectRatio._1X2, NativeSize.SMALL) 180 360
CreativeType.get(NativeAspectRatio._2X3, NativeSize.LARGE) 960 1440
CreativeType.get(NativeAspectRatio._2X3, NativeSize.MEDIUM) 480 720
CreativeType.get(NativeAspectRatio._2X3, NativeSize.SMALL) 192 288
CreativeType.get(NativeAspectRatio._3X2, NativeSize.LARGE) 1440 960
CreativeType.get(NativeAspectRatio._3X2, NativeSize.MEDIUM) 720 480
CreativeType.get(NativeAspectRatio._3X2, NativeSize.SMALL) 288 192
CreativeType.get(NativeAspectRatio._5X1, NativeSize.LARGE) 1800 360
CreativeType.get(NativeAspectRatio._5X1, NativeSize.MEDIUM) 900 180
CreativeType.get(NativeAspectRatio._5X1, NativeSize.SMALL) 360 72
CreativeType.get(NativeAspectRatio._1X5, NativeSize.LARGE) 360 1800
CreativeType.get(NativeAspectRatio._1X5, NativeSize.MEDIUM) 180 900
CreativeType.get(NativeAspectRatio._1X5, NativeSize.SMALL) 72 360

Need help?

If you are having any problems integrating, feel free to contact us on [email protected] and we will be more than happy to help.

What's next?

Now that you have successfully integrated a native ad into your app, what would you like to do next?