Menu

How to Test Ads

1. SDK Integration Verification

Note: Custom ad platforms do not support integration verification functionality.

1.1 Use Logs + Integration Verification API to Verify All Ad Platform Integrations

Call the following code to enable logging and integration detection:

objc Copy
#import <AnyThinkSDK/AnyThinkSDK.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [ATAPI setLogEnabled:YES];//Turn on debug logs
    [ATAPI integrationChecking];
    ....
    return YES;
}

Based on the output logs, check whether the SDK integration of each ad platform is normal.

The following table explains the meaning of each field:

Field Note
Status Status of integrated ad platform SDK
Reason Reason for integration issues
Recommended Versions Recommended third-party SDK versions to import
Use Versions Third-party SDK versions imported by users

1.2 Use DebugUI Debugging Tool to Verify Integration

Please go to the DebugUI debugging tool section.

2. Debug Ads

Taku dashboard ad placement configuration takes effect in about 5-15 minutes. After you modify related ad placement settings (such as adding or modifying ad sources), you may need to wait before they take effect.

SDK provides sandbox caching for dashboard configurations for 30 minutes. After you modify configurations, you need to wait for the cache time to end before requesting the latest dashboard configuration (expired cache will still use old configuration for that request).

You can choose one of the following three processes for testing based on your current development stage.

2.1 Use DebugUI Debugging Tool to Verify Your Online Ad Source Configuration (Suitable for verifying ad source configuration)

After you complete configuration in Taku dashboard and other ad platform dashboards, use the online ID testing function of DebugUI debugging tool to quickly verify whether these configurations are correct.

2.2 Use Debug Mode for Limited Ad Process Testing

  • When debugging overseas ad platforms, you may need to use proxy networks. InMobi is recommended to proxy to Southeast Asia, with India being optimal. Pangle should proxy to non-US regions. Other overseas platforms can try proxying to the platform's country/region to improve ad fill rates
  • Ad sources in debug mode are not 100% filled. For example, Meta ad platform requires Facebook app installed on test devices, using quality devices and proxy networks to get lower fill probability, because debug mode uses Taku's pre-configured ad sources
  • Only one ad platform can be debugged at a time. Please note to turn off this function after testing
  • After obtaining IDFA authorization, call the following API to configure test device IDFA, target ad platform and ad type
  • Debug mode parameter list can be found here

Note: Custom ad platforms are not supported.

objc Copy
#import <AnyThinkSDK/AnyThinkSDK.h>
 // Set test IDFA, such as Meta ad test devices
 [ATAPI setHeaderBiddingTestModeWithDeviceID:@"you device idfa"];
 // Note: Calling this code will use server-delivered ad configuration for ad requests. If testing is complete and you need to use your own ad configuration, remove this code.
 [ATAPI setDebuggerConfig:^(ATDebuggerConfig *debuggerConfig) {
    // Device idfa
    debuggerConfig.deviceIdfaStr = @"you device idfa";
    // Specify test ad platform, see header file for other platform types
    debuggerConfig.netWorkType = ATAdNetWorkCSJType;
    // Specify Pangle specific ad type
    debuggerConfig.csj_nativeAdType = ATCSJNativeAdFeedSelfRenderType;
  }];

2.3 Use Your Own Ad Placement and Ad Source Configuration for Testing (Suitable for production environment testing)

Remove DebugUI SDK, turn off debug mode, and fully use your app's ad display logic and Taku dashboard configuration for testing.

2.3.1 How to Test Ad Sources One by One (Custom Rules)

This can be achieved by configuring traffic groups and adding custom rules. First, refer to creating traffic groups with custom key-value rules. Put the ad sources to be tested in each traffic group (for example, traffic group A only contains Kuaishou, traffic group B only contains Tencent, here we demonstrate simulating Baidu), then test through the following code. (After adding the code, wait a few minutes for the dashboard traffic group configuration to take effect, then delete and reinstall the app for verification). For example:

⚠️Note

  • Remember to delete the test setCustomData code after debugging.
  • The following code is only for custom rules or custom rules (new).
  • You may need to add your test devices in each ad platform dashboard (if supported by the ad platform).

After dashboard modification, it takes about 5 minutes to take effect; local policy cache sandbox is 30 minutes. It is recommended to delete the app to clear sandbox cache after it takes effect, then request again.

objc Copy
//Set before calling various types of ad loading (load) APIs. Remember to delete the test setCustomData code after debugging
[[ATSDKGlobalSetting sharedManager] setCustomData:@{@"istest":@"yes"} forPlacementID:xxxx];

//Note: xxx is the actual parameter in the code
[[ATAdManager sharedManager] loadADWithPlacementID:xxx extra:xxx delegate:xxx];

2.3.2 How to Test a Batch of Ad Sources (Device IDFA Rules)

You can create test traffic groups and add your test device's IDFA. Then copy or create one or several ad sources you want to debug, wait for configuration to take effect, clear local cache, allow SDK to get IDFA (you can see SDK printing IDFA in initialization logs for success), then initiate ad loading to attach device IDFA information for ad requests. If your ad loading request is made after getting IDFA, you need to adjust system time 30 minutes later, return to the app and request again, and repeat this operation once to update sandbox policy cache.

2.4 Request Ads Using Your Own Configured Ad Sources

Test Ads: Please go to ad platform dashboard to add test devices (if supported by ad platform).

Production Ads: Cannot control fill rate, affected by multiple factors. Tips to increase production non-bidding ad fill rate: 1. Lower fixed price configuration; 2. Try more node devices for overseas ad platforms; For overseas projects, please check if app-ads.txt is correctly configured before testing production bidding ads (both Taku and third-party platforms need to be checked. For third-party ad platforms, please refer to their documentation for app-ads.txt configuration tutorials).

3. View Ad Loading Failure Reasons

3.1 Add Printing for Ad Placement and Ad Source Delegates

Ad source delegate methods can output original information from third-party ad platform SDKs, which is very useful for troubleshooting ad loading failure reasons.

  • One ad placement can configure multiple ad sources. To receive loading events for a specific ad source, you need to use ad source level delegate callback methods. If all ad sources fail to request, or the ad placement overall request times out, use ad placement level failure callback to receive events.

  • After enabling SDK log switch, SDK will print ad source loading failure information by default. If you want to collect and print this information yourself, please implement these delegate methods.

  • If your ad sources include bidding ads, you need to implement the following BiddingADSource delegate methods to get ad source bidding related information.

  • Print the description field in error object to view detailed error information. You can go to Error Code Description document to view error code meanings.

objc Copy
#pragma mark - Ad Source Level Callbacks
- (void)didStartLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"Ad Source--AD--Start--didStartLoadingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFinishLoadingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"Ad Source--AD--Finish--didFinishLoadingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFailToLoadADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error {
    NSLog(@"Ad Source--AD--Fail--didFailToLoadADSourceWithPlacementID:%@---error:%@", placementID,error);
}

/*
If your ad sources include bidding ads, you need to implement the following delegate methods to get ad source bidding process information. If bidding fails, you can provide related failure information and give us feedback, or directly check third-party platform error code descriptions.
*/
#pragma mark - Ad Source Level Callbacks - Bidding
- (void)didStartBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"Ad Source--bid--Start--didStartBiddingADSourceWithPlacementID:%@---extra:%@", placementID,extra);
}

- (void)didFinishBiddingADSourceWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"Ad Source--bid--Finish--didFinishBiddingADSourceWithPlacementID:%@--extra:%@", placementID,extra);
}

- (void)didFailBiddingADSourceWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra error:(NSError*)error {
    NSLog(@"Ad Source--bid--Fail--didFailBiddingADSourceWithPlacementID:%@--extra:%@--error:%@", placementID, extra, error);
}

#pragma mark - Ad Placement Level Callbacks - All Ad Sources Loading Complete
//Success - Some ad source loaded successfully
- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"didFinishLoadingADWithPlacementID:%@", placementID);
}

//Failure - No ad source loaded successfully
- (void)didFailToLoadADWithPlacementID:(NSString *)placementID error:(NSError *)error {
    NSLog(@"didFailToLoadADWithPlacementID:%@ error:%@", placementID, error);
}

Here is an actual printing case. Usually you need to pay attention to the following points when troubleshooting:

  • Error Domain=com.anythink.PubNativeSDK : Describes which package the error comes from
  • Code=1 : Taku or third-party SDK error code
  • NSLocalizedDescription=HyBid - No fill : Specific meaning of the error, where No fill usually means no ads returned
  • adsource_id = "2560962" : Taku ad source ID where the error occurred
  • ATAdLogger(UA_6.4.87) : SDK version
objc Copy
ATAdLogger(UA_6.4.87) Message:didFailBiddingADSourceWithPlacementID:b5bacaccb61c29extra:{
	adunit_id = "b5bacaccb61c29";
	currency = "USD";
	adsource_price = 0;
	req_id = "cee21cc4b7ae08706a1a3ef3fc9060ba";
	abtest_id = 609;
	s_id = 100172;
	usd_to_rmb_rate = "1";
	rmb_to_usd_rate = "0.1393";
	network_firm_id = 58;
	adsource_id = "2560962";
	network_placement_id = "9";
	adsource_bid_type = 2;
}error:Error Domain=com.anythink.PubNativeSDK Code=1 "AnythinkSDK has failed to load native ad." UserInfo={NSLocalizedDescription=AnythinkSDK has failed to load native ad., NSLocalizedFailureReason=Error Domain=net.pubnative.PubnativeLite Code=1 "HyBid - No fill" UserInfo={NSLocalizedDescription=HyBid - No fill}}

3.2 Console Log Analysis

You can quickly get the following debugging information through console printed log information.

  • From Xcode logs, you can see tracking of various ad actions.
  • Locate the ad placement to be verified based on placement_id.
  • The action field in logs is the action corresponding to the log after initiating ad loading, including lrequest (ad request), request_result (ad return result), impression (ad display), click (ad click), close (ad close).

Log Example:

json Copy
{
    action = "request_result"; //Action after initiating ad loading: request (ad request), request_result (ad return result), impression (ad display), click (ad click), close (ad close)
    "ad_type" = reward; //Ad placement type for loading: Native/inter/RewardVideo/Banner/Splash
    "adsource_id" = 12300; //Ad source id
    auto = NO; //Whether it's automatic request
    "daily_frequency" = 0; //Number of displays the day before
    "hourly_frequency" = 0; //Number of displays in current hour
    defaultAdSourceType = 0; //Whether it's fallback ad source
    isheaderbidding = 0; //Whether it's bidding ad source
    msg = "Error Domain=Wind Code=600008 \"\U8bf7\U6c42\U8d85\U65f6\U3002\" UserInfo={NSLocalizedDescription=\U8bf7\U6c42\U8d85\U65f6\U3002}";  //If loading fails, complete error information will be output here
    network = Sigmob; //Represents third-party platform
    "network_firm_id" = 29; //Represents third-party platform's network_firm_id
    "network_list" =     (
        Sigmob
    );//Current third-party ad request list id, separated by ","
    "network_unit_info" =     {
        "app_id" = 19761;
        "app_key" = 7064a19c108082ef;
        "placement_id" = ea1f8f7b662;
    };  //Corresponding third-party ad platform app and placement information
    "placement_id" = b5d771f5a3458f; //Ad placement id that initiated loading
    position = 0; //Current ad source sort position
    refresh = 0;  //Whether it's auto refresh
    "request_network_num" = 1; //How many third-party ad platform loadings are initiated simultaneously
    result = fail;  //Result parameter: success, fail
    "sdk_version" = "4.2.1"; //Third-party platform SDK version
    "segment_id" = 0; //Traffic group id
}

3.3 Log Analysis Examples

Taku ads are divided into waterfall ads and bidding ads. The loading process of these two types of ads is slightly different. Bidding ads will first get bidding tokens without initiating loading yet, while waterfall ads directly initiate ad requests to ad platforms.

Initiate Ad Source Ad Request, search for "AD Request offer with network info:" in console, result as shown:

Annotations in the figure:

① Ad source layer in ad placement initiates request

② Which ad platform the ad source layer in ad placement is, locate which ad platform

③ Related information of ad source platform in ad placement, ad platform information configured in Taku.

Ad Source Ad Request Success, search for "handler success Request offer with network info:" in console, result as shown:

Annotations in the figure:

① Ad source layer in ad placement request successful

② Which ad platform the ad source layer in ad placement is

③ SDK version of ad source platform in ad placement, can know the imported third-party platform SDK version

④ Traffic group id for ad placement loading, can know which traffic group is loaded, 0 represents default group

Ad Source Ad Request Failure, search for "handler fail Request offer with network info:" in console, result as shown:

Annotations in the figure:

① Ad source layer in ad placement request failed.

② Ad source layer loading failure information in ad placement. Based on which platform's ad, use error information to check corresponding platform's error codes.

③ Which ad platform the ad source layer in ad placement is.

  • Impression with ad info: Ad display information. If display is abnormal, you can search this print to see which ad source's ad.
  • Close with ad info: Ad close information.
  • ATADLogger(UA_6.4.87) Parentheses indicate integrated Taku SDK version, ATADLogger is SDK log keyword.
Previous
Testing Networks
Next
DebugUI Debug Tool
Last modified: 2025-07-30Powered by