Native Cross Promotion

Native ads are flexible ad units which are stored in a TDNativeAd 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.1

1. Register a placement tag

To begin preparations for displaying a native ad, go back to your Settings panel, and make sure TDAdType2x1Medium has registered ingame tag:

Native Ad - Register Tag

Note: Here we use the example of a "ingame", but you can use any custom string e.g. "my_custom_tag". You can also add multiple placement tags by comma-separating them e.g. "ingame,my_custom_tag".

Here are a list of all the possible TDNativeAdTypes.

2. Load the native ad

You can load a native ad given a placement tag and native ad type, like so:

AdManager.LoadNativeAdvertForTag("ingame", TDNativeAdType2x1Medium);

If you would like to load the interstitial when the application starts, use the TapdaqConfigLoaded listener to guarantee the ad is loaded.

private void OnEnable() {
	TDCallbacks.TapdaqConfigLoaded += OnTapdaqConfigLoaded;
}

private void OnDisable() {
	TDCallbacks.TapdaqConfigLoaded -= OnTapdaqConfigLoaded;
}

private void OnTapdaqConfigLoaded(string message) {
	AdManager.LoadNativeAdvertForTag("ingame", TDNativeAdType2x1Medium);
}

3. Fetch the native ad

After the native ad has been loaded, you need to create a NativeAd object which will later be used to send impressions, clicks, and display the native ad.

private TDNativeAd myNativeAd;

private void OnEnable() {
	TDCallbacks.AdAvailable += OnAdAvailable;
}

private void OnDisable() {
	TDCallbacks.AdAvailable -= OnAdAvailable;
}

private void OnAdAvailable(TDAdEvent e) {
	if (e.adType == "NATIVE_AD" && e.tag == "ingame") {
		myNativeAd = AdManager.GetNativeAd(TDNativeAdType.TDNativeAdType2x1Medium, "ingame");
	}
}

4. Display the native ad

Create a method that takes a TDNativeAd, TDNativeAdType, and Image as parameters, and then pass this Method as a delegate to the LoadTexture method on a Native Ad object, as seen below.

private void DisplayNativeAd(TDNativeAd myNativeAd, Image image, TDNativeAdType nativeAdType) {
	var texture = myNativeAd.texture;
	if (texture == null) {
		Debug.LogError ("Texture not loaded");
		return;
	}

	var sprite = Sprite.Create (texture, new Rect (0, 0, texture.width, texture.height), Vector2.one * 0.5f);
	if (sprite != null) {
		image.rectTransform.sizeDelta = nativeAdType.ToVector2 ();
		image.sprite = sprite;
		image.gameObject.SetActive (true);
	}
}

public void ShowNativeAd() {
	myNativeAd.LoadTexture((TDNativeAd obj) => {
		DisplayNativeAd(obj, imageGameObject, TDNativeAdType.TDNativeAdType2x1Medium);
	});
}

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:

AdManager.SendNativeImpression(nativeAd);

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, or a custom URL.

To trigger a click, use the following:

AdManager.SendNativeClick(nativeAd);

Export your application to iOS and Android, then run your application to test the ad displays correctly.

6. Native ad sizes

When you are creating your UI for your native ad you may use the following extension method to get the size as a Vector2.

.ToVector2 ()

TDNativeAdType Width Height
TDNativeAdType1x1Large 750 750
TDNativeAdType1x1Medium 375 375
TDNativeAdType1x1Small 150 150
TDNativeAdType1x2Large 900 1800
TDNativeAdType1x2Medium 450 900
TDNativeAdType1x2Small 180 360
TDNativeAdType2x1Large 1800 900
TDNativeAdType2x1Medium 900 450
TDNativeAdType2x1Small 360 180
TDNativeAdType2x3Large 960 1440
TDNativeAdType2x3Medium 480 720
TDNativeAdType2x3Small 192 288
TDNativeAdType3x2Large 1440 960
TDNativeAdType3x2Medium 720 480
TDNativeAdType3x2Small 288 192
TDNativeAdType1x5Large 360 1800
TDNativeAdType1x5Medium 180 900
TDNativeAdType1x5Small 72 360
TDNativeAdType5x1Large 1800 360
TDNativeAdType5x1Medium 900 180
TDNativeAdType5x1Small 360 72

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?