Add Targeting Parameters
In this example, we get the user's location from Android and pass it along in the ad call:
This code assumes you provided the application location access by setting one or both of the
Developers should ensure adequate consent is obtained before sharing location information. Developers can control whether location is collected and sent by the SDK.
By default, the Android SDK automatically transmits location information if the Android Manifest allows location permissions to the app. If adequate permissions have not been obtained, or for any other reason, developers are able to instruct the SDK to not send the location. To disable the SDK from sending location, you can call:
Note that this is a global setting for the AppNexus SDK only. Keep in mind that third Party SDKs will have their own settings.
Age and gender
Advertisers may want to target ads by age and gender. In this example, we add the age and gender to an
In this snippet, we create an
ANLocation object and set its latitude and longitude. We also set the horizontal accuracy, which is the size of one side of the "rectangle" inside which the user is located. Finally, we set the ad view's location property to our
Note: Developers should ensure adequate consent is obtained before sharing location information. Developers can control whether location is collected and sent by the SDK.
By default, the iOS SDK does not automatically send location information. In order for the SDK to use location information for ad targeting, the app developer must explicitly pass the location information to the SDK.
Age and Gender
Age and gender can be added to the banner ad view directly as shown below. Note that age is an
NSString, and can contain a numeric age, a birth year, or a hyphenated age range. For example, it could be "56", "1974", or "25-35".