User Data

For better ad targeting, you can optionally specify the user's gender and age. If your app uses its own localization model, you can also specify the chosen locale in ISO 639-1 format (e.g. "ru", "en", "fr", etc.).
Android
To specify user data, use the customParams property on the created API instance.

private NativeAd ad;
 
private void initAd()
{
    // Create an instance of NativeAd
    ad = new NativeAd(YOUR_SLOT_ID, this);
  
    // Get an instance of CustomParams
    CustomParams customParams = ad.getCustomParams();
    // Set the age
    customParams.setAge(25);
    // Set the gender
    customParams.setGender(CustomParams.Gender.MALE);
}
iOS
To specify user data, use the customParams property on the created API instance.

@interface YourViewController : UIViewController
@end
 
@implementation YourViewController
{
  MTRGNativeAd *_ad;
}
 
- (void)initAd
{
    // Create an instance of MTRGNativePromoAd
    _ad = [MTRGNativeAd nativeAdWithSlotId:YOUR_SLOT_ID];
  
    // Set the age
    _ad.customParams.age = [NSNumber numberWithInt:25];
    // Set the gender
    _ad.customParams.gender = MTRGGenderMale;
}
Unity
To specify user data, use the CustomParams property on the created API instance.


private MyTargetView _myTargetView;
 
private void InitAd()
{
    // Create an instance of MyTargetView
    _myTargetView = new MyTargetView(YOUR_SLOT_ID);
  
    // Set the age
    _myTargetView.CustomParams.Age = 23;
    // Set the gender
    _myTargetView.CustomParams.Gender = CustomParams.GenderEnum.Male; 
}
Was this article helpful?